Skip to content

Commit

Permalink
Fix Exiting Early
Browse files Browse the repository at this point in the history
With the exit 1 command inside the loop, your script will terminate immediately upon finding the first missing tool. If your intent is to check for all missing tools and then provide a summary, you'd want to move the exit 1 outside of the loop.
  • Loading branch information
ckvsoft authored Oct 16, 2023
1 parent f73a23c commit ddf40d7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions scripts/controller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,14 @@ for tool in $tools; do
if ! which "$tool" >/dev/null; then
echo "E: Please ensure the tool '$tool' is found."
num_tools_missing=$((num_tools_missing + 1))
exit 1
fi
done
if [ 0 -lt $num_tools_missing ]; then
echo "E: Found $num_tools_missing tool(s) missing."
exit 1

if [ $num_tools_missing -gt 0 ]; then
echo "E: $num_tools_missing tools are missing."
exit 1
fi

unset num_tools_missing

########## Begin of the script...
Expand Down

0 comments on commit ddf40d7

Please sign in to comment.