[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bash bug
From: |
Weshakie Löwe |
Subject: |
Bash bug |
Date: |
Mon, 22 Aug 2016 20:34:13 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
When storing the value of code executed in a subshell the return value
is always 0 if the variable is local.
Code example:
A(){
local return_value="$(bash -c "exit 1")"
echo $?
}
function A: returns 0 - even though obviously the return value is 1.
B(){
return_value="$(bash -c "exit 1")"
echo $?
}
function B: returns 1 - as expected, the only difference to function A
being not using a local variable to store the value.
Best regards,
A happy bash user
- Bash bug,
Weshakie Löwe <=