Re: PIPESTATUS differs from $? for compound command

2024-12-09 Thread Mike Jonkmans
On Mon, Dec 09, 2024 at 06:21:53PM +0100, Ulrich Müller wrote: > 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,

Re: PIPESTATUS differs from $? for compound command

2024-12-09 Thread Andreas Schwab
On Dez 09 2024, Mike Jonkmans wrote: > So, with 'if false; then :; fi', the whole if has 0 as status, due to #1. > The last pipeline is the 'false' command. So $PIPESTATUS = 1. Why is `if false; then :; fi' not a pipeline? It is a command, and the components of a pipeline are commands. > Both o

PIPESTATUS differs from $? for compound command

2024-12-09 Thread Ulrich Müller
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 Radeo

Re: PIPESTATUS differs from $? for compound command

2024-12-09 Thread microsuxxor
its a pass return codes passthru question .. .. id like it passthru too , that it returns the upper cmds return codes .. On Mon, Dec 9, 2024, 6:22 PM Ulrich Müller wrote: > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: x86_64-p

Re: PIPESTATUS differs from $? for compound command

2024-12-09 Thread Mike Jonkmans
On Mon, Dec 09, 2024 at 09:20:54PM +0100, Andreas Schwab wrote: > On Dez 09 2024, Mike Jonkmans wrote: > > So, with 'if false; then :; fi', the whole if has 0 as status, due to #1. > > The last pipeline is the 'false' command. So $PIPESTATUS = 1. > Why is `if false; then :; fi' not a pipeline? It

Re: PIPESTATUS differs from $? for compound command

2024-12-09 Thread Dale R. Worley
Andreas Schwab writes: >> But the PIPESTATUS refers to the 'false' pipeline: >> $ if false; then :; fi; echo ${PIPESTATUS[*]} >> 1 > > $ if false; then :; fi | true; echo ${PIPESTATUS[*]} > 0 0 > > Why is that not `1 0'? After all, the last executed commands as part of > the pipeline (b

Re: PIPESTATUS differs from $? for compound command

2024-12-09 Thread microsuxxor
the | true is the.last pipe while witbout , its.one cmd less the | true is $pipestatus[1][*] On Tue, Dec 10, 2024, 4:31 AM Dale R. Worley wrote: > Andreas Schwab writes: > >> But the PIPESTATUS refers to the 'false' pipeline: > >> $ if false; then :; fi; echo ${PIPESTATUS[*]} > >> 1 >

Re: PIPESTATUS differs from $? for compound command

2024-12-09 Thread Andreas Schwab
On Dez 09 2024, Mike Jonkmans wrote: > But the PIPESTATUS refers to the 'false' pipeline: > $ if false; then :; fi; echo ${PIPESTATUS[*]} > 1 $ if false; then :; fi | true; echo ${PIPESTATUS[*]} 0 0 Why is that not `1 0'? After all, the last executed commands as part of the pipeline