Exit inside parentheses doesn't exit script

Several error conditions were resulting in a message printed and "exit"
being called, however expressions inside parentheses are executed in a
subshell; consequently the *subshell* would exit but the parent shell
continued running the script.

https://stackoverflow.com/questions/19886797/exit-inside-parentheses-doesnt-exit-script
This commit is contained in:
Luke Smith
2018-04-23 15:06:45 -07:00
committed by Lyle Hanson
parent d755931c52
commit 07b5776f0b
2 changed files with 3 additions and 4 deletions

View File

@@ -5,7 +5,7 @@
#DO NOT RUN THIS YOURSELF because Step 1 is it reformatting /dev/sda WITHOUT confirmation,
#which means RIP in peace qq your data unless you've already backed up all of your drive.
pacman -S --noconfirm dialog || (echo "Error at script start: Are you sure you're running this as the root user? Are you sure you have an internet connection?" && exit)
pacman -S --noconfirm dialog || { echo "Error at script start: Are you sure you're running this as the root user? Are you sure you have an internet connection?"; exit; }
RED='\033[0;31m'
BLUE='\033[0;34m'
NC='\033[0m'