On Mon, Feb 10, 2025 at 15:20:55 +0100, Phi Debian wrote: > If 'best *general*' refer to the shortest line noise does > > $((${i/?([-+])/&10#})) > > Qualify for better than best ? :-) if so you may add in your web bible > don't forget to mention the inventor :-)
Can you please explain *how* this is working in older bash versions? According to the CHANGES file, the processing of `&' by patsub_replacement is new in bash 5.2. And yet: hobbit:~$ bash-2.05b bash-2.05b: /home/greg/.bashrc: line 95: syntax error in conditional expression: unexpected token `(' bash-2.05b: /home/greg/.bashrc: line 95: syntax error near `+([' bash-2.05b: /home/greg/.bashrc: line 95: ` if [[ $letters != +([A-Z]) ]]; then' hobbit:~$ shopt | grep extglob extglob off hobbit:~$ var=-023 hobbit:~$ echo "$(( ${var/?([-+])/&10#} ))" -19 So, not only is the & being respected, but the extended glob is also working, despite extglob being visibly disabled. Not to mention, this version is decades older than the patsub_replacement feature, at least according to the documentation we have.