bug-bash
[Top][All Lists]
Advanced

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

grouping via {} fails after "test $PIPESTATUS"


From: Steve Newcomb
Subject: grouping via {} fails after "test $PIPESTATUS"
Date: Sat, 24 May 2025 10:43:39 -0400
User-agent: Mozilla Thunderbird

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wall uname output: Linux moe 6.1.0-32-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.129-1 (2025-03-06) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.2
Patch Level: 15
Release Status: release

Description: In the following script,

#!/bin/bash
true && {
    echo here 1
    test "$PIPESTATUS" "!=" "0"
    #echo here 2
} || {
    echo here 3
}

The output is:
here 1
here 3   ("here 3" should never be output, I think, because of the grouping)

If "#echo here 2" is uncommented the output is
here 1
here 2   (which is what I would expect)

Another way to get the correct behavior is to change "$PIPESTATUS" to, e.g. "$PATH".  Then the output is:
here 1


#!/bin/bash
true && {
    echo here 1
    test "$PIPESTATUS" "!=" "0"
    #echo here 2
} || {
    echo here 3
}




reply via email to

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