Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15063

Re: How to tell Bash multiple values are success?

From Eli Schwartz <eschwartz@archlinux.org>
Newsgroups gnu.bash.bug
Subject Re: How to tell Bash multiple values are success?
Date 2019-06-19 11:14 -0400
Message-ID <mailman.460.1560957300.10840.bug-bash@gnu.org> (permalink)
References <CAH8yC8nj-JmJH_C+=6EPy7JmgG7JsOyx973DdMF6kTpcVAcZRg@mail.gmail.com> <fd8e53d9-1830-ec94-e94f-0877f28ce3a5@archlinux.org>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 6/19/19 11:01 AM, Jeffrey Walton wrote:
> Hi Everyone,
> 
> I have a systemd service that automatically applies updates. Looking
> at the service history, the service reports failure when it installs
> updates due to this:
> 
>     if dnf -y update &>/dev/null
>     then
>         echo "Upgraded system"
>     else
>         echo "Failed to upgrade system"
>         exit 1
>     fi
> 
> The problems seems to be 0, 100 and 200 are success. When updates are
> installed either 100 or 200 is returned. Confer,
> https://dnf.readthedocs.io/en/latest/command_ref.html .
> 
> I looked through Bash Variables, but I did not see a way to signal the
> information to Bash. Confer,
> https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html
> .
> 
> How do I tell Bash 0, 100 and 200 are success? (Or, how to tell Bash 1
> is the only failure?)

Neither 100 nor 200 are successes, and the page you linked explains
exactly why.

The former is only relevant to the subcommand "dnf check-update" and
indicates that your system is *not* fully upgraded and you should fix that.

The latter indicates that you successfully updated the system, but
potentially bad things occurred in the process. You can choose to
*ignore* selected errors, however, using Greg's suggestion.

There is no option to make bash dramatically redefine its entire
internal understanding of how basic unix return codes work.

-- 
Eli Schwartz

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: How to tell Bash multiple values are success? Eli Schwartz <eschwartz@archlinux.org> - 2019-06-19 11:14 -0400

csiph-web