[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
use of set -e inside parenthesis and conditionnal second command
From: |
Pierre Colombier |
Subject: |
use of set -e inside parenthesis and conditionnal second command |
Date: |
Tue, 17 Nov 2020 09:35:35 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2
-fdebug-prefix-map=/build/bash-2bxm7h/bash-5.0=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall$
uname output: Linux zebulon 4.19.0-11-amd64 #1 SMP Debian 4.19.146-1
(2020-09-17) x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.0
Patch Level: 3
Release Status: release
Description:
I'm not sure this is actually a bug since dash act the same way
but it's quite unexpected for the average user and the manual suggests
it should not act like this.
The solution may be to improve the manual instead of fixing the software.
Please, consider the 3 next lines
#1
pierre@zebulon: ~ $ (set -e ; echo A ; false ; echo B ) ; echo C.$?
A
C.1
#Works fine
#2
pierre@zebulon: ~ $ (set -e ; echo A ; false ; echo B ) && echo C.$?
A
B
C.0
#Surprising
#3
pierre@zebulon: ~ $ bash -c 'set -e ; echo A ; false ; echo B ' && echo C.$?
A
#This line works like I was expecting for #2
Repeat-By:
already explained in description
Fix:
no idea.
If it's not a bug, I think the manual should explain the difference
between #2 and #3 in section 3.2.3 and 3.2.4.3
- use of set -e inside parenthesis and conditionnal second command,
Pierre Colombier <=