bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ="${@:...}" and ="${@/...}" join with IFS since after 4.4


From: Emanuele Torre
Subject: Re: ="${@:...}" and ="${@/...}" join with IFS since after 4.4
Date: Sun, 16 Nov 2025 01:42:51 +0100
User-agent: Mutt/2.2.14 (2025-02-20)

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]