Why does this compound command {...} not exit on error, when used with ||?
4
votes
2
answers
1465
views
I'm trying to run this script:
#!/bin/bash -e
{
echo "Doing something";
will_fail # like
false
echo "Worked";
} || echo "Failed"
To my surprise, will_fail
failed, but I did not see "Failed" on my command line, but "Worked".
Why did the compound command not exit with error after will_fail
failed?
Asked by Minix
(6065 rep)
Sep 22, 2017, 09:40 AM
Last activity: Dec 23, 2021, 02:58 PM
Last activity: Dec 23, 2021, 02:58 PM