2023年12月10日(日) 14:13 Martin D Kealey <mar...@kurahaupo.gen.nz>: > But even if you still thought this was worth doing, it wasn't necessary to > make $((10#)) completely illegal: Bash could look ahead and only intervene > if the following character is '-' (affecting $((10#-digits)) but not > $((10#))).
I'm not a big fan of `10#[-+]digits' and invalidating `10#' either since the Bash change also broke mine [1,2], but I'd say the above lookahead switching is worse than the current behavior. In the above way, there is still a backward compatibility problem with $((10#$X-digits)) with an empty X. One might suggest that the arithmetic lexer can reference the original string before the shell expansions, but the arithmetic evaluation does not work in that way. For example, there is the same problem with « let "10#$X-digits" » where the shell expansion and the arithmetic evaluation are clearly separated. It's too late, but a better way could have been introducing the function-call syntax and supporting signed n-adic numbers through e.g. « int([-+]digits, n) ». [1] https://github.com/akinomyoga/ble.sh/commit/2ea48d7cd4fe2a808b20e3c4c81f662f5a5f5451 [2] https://github.com/akinomyoga/ble.sh/commit/7545ea31bda2e34e25b53c6550270397ccc77361