bug-bash
[Top][All Lists]
Advanced

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

Inconsistent treatment of left-hand side of conditional expression where


From: Kerin Millar
Subject: Inconsistent treatment of left-hand side of conditional expression where IFS is not its default value
Date: Sun, 18 Feb 2024 22:03:23 +0000

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

-- 
Kerin Millar



reply via email to

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