How can I throw error from nested shell script and make parent shell script to stop as well?
I have this shell script (a.sh)
#!/bin/bash
echo "Testing if SDK build config is correct"
FILE="App/env/index.tsx"
CONST_TO_CHECK='[a-zA-Z_]*'
RED=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`
if grep -Eq 'export\s*const\s*'${CONST_TO_CHECK}'\s*=\s*false' "$FILE"; then
echo "${RED}Error: All values should be true for sdk build in env.ts file${reset}"
exit 1
fi
echo "${green}Build config seems correct${reset}"
Which I run from b.sh
. If a.sh
throws error, I want to stop further execution in b.sh as well.
I am calling b.sh from a.sh.
Consider this to be my b.sh
#!/bin/bash
sh ./a.sh
rm -rf ios/ios-sdk/out/Frameworks
xcodebuild clean \
-workspace ios/dyteClientMobile.xcworkspace \
-scheme DyteSdk