Skip to content

Commit

Permalink
Move the error handling lower in the script so I can make use of the …
Browse files Browse the repository at this point in the history
…error_msg function
  • Loading branch information
Antiz96 committed Jun 20, 2024
1 parent ac4b0a7 commit f6bc2d1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/script/arch-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,6 @@ fi

if grep -Eq '^[[:space:]]*PrivilegeElevationCommand[[:space:]]*=[[:space:]]*(sudo|doas|run0)[[:space:]]*$' "${config_file}" 2> /dev/null; then
su_cmd=$(grep -E '^[[:space:]]*PrivilegeElevationCommand[[:space:]]*=[[:space:]]*(sudo|doas|run0)[[:space:]]*$' "${config_file}" 2> /dev/null | awk -F '=' '{print $2}' | tr -d '[:space:]')
if ! command -v "${su_cmd}" > /dev/null; then
error_msg "$(eval_gettext "The \${su_cmd} command set for privilege escalation in the arch-update.conf configuration file is not found\n")" && quit_msg
exit 2
fi
fi

# Definition of the colors for the colorized output
Expand Down Expand Up @@ -154,6 +150,11 @@ if [ -z "${su_cmd}" ]; then
error_msg "$(eval_gettext "A privilege elevation command is required (sudo, doas or run0)\n")" && quit_msg
exit 2
fi
else
if ! command -v "${su_cmd}" > /dev/null; then
error_msg "$(eval_gettext "The \${su_cmd} command set for privilege escalation in the arch-update.conf configuration file is not found\n")" && quit_msg
exit 2
fi
fi

# Definition of the AUR helper to use (depending on if/which one is installed on the system) for the optional AUR packages support
Expand Down

0 comments on commit f6bc2d1

Please sign in to comment.