Skip to content

Commit

Permalink
fix: Fix exit status code 7 for the --list option (#212)
Browse files Browse the repository at this point in the history
The exit status code 7 invoked if there are no pending update when using the `-l/--list` option was not honored because of the `sed` part piped into the call of the `list_package` function. Indeed, piped commands are executed in their own subshell, so the subshell invoked by the `| sed` part is exited with status code 7 instead of the parent subshell (see https://www.gnu.org/software/bash/manual/html_node/Pipelines.html & https://relentlesscoding.com/posts/bash-commands-in-pipelines-subshells/ for more details).
Given the very little benefit this `sed` part brings (namely removing the last blank line of the output for purely aesthetic reason), it's not worth wrapping our head too hard on this. Let's just drop it.

This commit also adds an info message that there is no update available for the -l/--list option (if that's the case).

Fixes #211
  • Loading branch information
Antiz96 authored Jul 9, 2024
1 parent 7a4eb4a commit 814c489
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/script/arch-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ list_packages() {

if [ -z "${packages}" ] && [ -z "${aur_packages}" ] && [ -z "${flatpak_packages}" ]; then
state_up_to_date
if [ -z "${list_option}" ]; then
info_msg "$(eval_gettext "No update available\n")"
else
info_msg "$(eval_gettext "No update available\n")"

if [ -n "${list_option}" ]; then
exit 7
fi
else
Expand Down Expand Up @@ -796,7 +796,7 @@ case "${option}" in
;;
-l|--list)
list_option="y"
list_packages | sed '${/^$/d;}'
list_packages
;;
-n|--news)
show_news="y"
Expand Down

0 comments on commit 814c489

Please sign in to comment.