[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
PIPESTATUS differs from $? for compound command
From: |
Ulrich Müller |
Subject: |
PIPESTATUS differs from $? for compound command |
Date: |
Mon, 09 Dec 2024 18:21:53 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: x86_64-pc-linux-gnu-gcc
Compilation CFLAGS: -march=native -ggdb -O2 -pipe
uname output: Linux urania 6.6.62-gentoo #1 SMP Wed Nov 20 14:40:27 CET 2024
x86_64 AMD Ryzen 7 PRO 7730U with Radeon Graphics AuthenticAMD GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.2
Patch Level: 37
Release Status: release
Description:
For a compound command like "if" or "while" and with
an unsuccessful test, the last element of PIPESTATUS is not the
return status of the compound but that of the test command.
For example, "if false; then :; fi" returns 0 but ${PIPESTATUS[0]}
is 1.
If the pipeline consists of more than one command, like
"if false; then :; fi | true" or "true | if false; then :; fi"
then it behaves as I would expect, i.e. all elements of
PIPESTATUS are zero.
Repeat-By:
$ if false; then :; fi
$ echo "ret = $?, status = ${PIPESTATUS[*]}"
ret = 0, status = 1
- PIPESTATUS differs from $? for compound command,
Ulrich Müller <=
- Re: PIPESTATUS differs from $? for compound command, microsuxxor, 2024/12/09
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/09
- Re: PIPESTATUS differs from $? for compound command, Andreas Schwab, 2024/12/09
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/09
- Re: PIPESTATUS differs from $? for compound command, Andreas Schwab, 2024/12/09
- Re: PIPESTATUS differs from $? for compound command, Dale R. Worley, 2024/12/09
- Re: PIPESTATUS differs from $? for compound command, microsuxxor, 2024/12/09
- Re: PIPESTATUS differs from $? for compound command, Dale R. Worley, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Mike Jonkmans, 2024/12/10
- Re: PIPESTATUS differs from $? for compound command, Andreas Schwab, 2024/12/10