On Sun, Nov 16, 2025 at 01:23:35AM +0100, Emanuele Torre wrote:
> Normally "$@"/"${arr[@]}" on the RHS side of an assignment joins the
> elements with ' ' even if IFS is set to a string with a first character
> that is not space.
It has been pointed out to me that ${@#?} (and likewise %%.. %.. ##..)
also always uses IFS in this context, similarly to ${@@Q}:
bash-5.3$ set aa bb cc; IFS=: o=${@#?}; declare -p o
declare -- o="a:b:c"
bash-5.3$ set aa bb cc; IFS=: o="${@#?}"; declare -p o
declare -- o="a:b:c"
I initially did not notice this because I tested it with ${@#} with no
pattern and in that case, it ${@#} behaves the same way as $@ does and
always uses space
bash-5.3$ set a b c; IFS=: o=${@#}; declare -p o
declare -- o="a b c"
bash-5.3$ set a b c; IFS=: o="${@#}"; declare -p o
declare -- o="a b c"
So, while $@, ${@^}, etc. will always use space as they did in bash 4.4-
bash is not actually as consistent as I initially thought.
o/
emanuele6