On Sun, Feb 18, 2024, at 5:03 PM, Kerin Millar wrote:
> Hi,
>
> This report stems from the discussion at 
> https://lists.gnu.org/archive/html/help-bash/2024-02/msg00085.html.
>
> Consider the following two cases.
>
> $ ( set a -- b; f=+ IFS=$f; [[ $f$*$f == *"$f--$f"* ]]; echo $? )
> 0
>
> $ ( set a -- b; f=$'\1' IFS=$f; [[ $f$*$f == *"$f--$f"* ]]; echo $? )
> 1
>
> It does not make sense that that the exit status value differs between 
> these cases, especially since SOH is not a whitespace character (in the 
> sense of field splitting). I think that the second case should also 
> yield 0. Regardless of what the intended behaviour is, I would also 
> expect for the manual to describe it.
>
> Note that quoting the left-hand side fixes it for SOH. In the absence 
> of quotes, xtrace output suggests that all of the SOH characters are 
> stripped from the expansion of $f$*$f.
>
> $ ( set a -- b; f=$'\1' IFS=$f; [[ "$f$*$f" == *"$f--$f"* ]]; echo $? )
> 0

Case commands exhibit similar behavior:

$ set a -- b
$ (f=+ IFS=$f; case $* in *"$f"*) echo 0;; *) echo 1;; esac)
0
$ (f=$'\1' IFS=$f; case $* in *"$f"*) echo 0;; *) echo 1;; esac)
1
$ (f=$'\1' IFS=$f; case "$*" in *"$f"*) echo 0;; *) echo 1;; esac)
0


-- 
vq

Reply via email to