bug-bash
[Top][All Lists]
Advanced

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

Re: Inconsistent treatment of left-hand side of conditional expression w


From: Lawrence Velázquez
Subject: Re: Inconsistent treatment of left-hand side of conditional expression where IFS is not its default value
Date: Sun, 18 Feb 2024 17:25:18 -0500
User-agent: Cyrus-JMAP/3.11.0-alpha0-144-ge5821d614e-fm-20240125.002-ge5821d61

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

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