bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to tell Bash multiple values are success?


From: Greg Wooledge
Subject: Re: How to tell Bash multiple values are success?
Date: Wed, 19 Jun 2019 11:08:20 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Wed, Jun 19, 2019 at 11:01:46AM -0400, Jeffrey Walton wrote:
>     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 .

dnf -y update >/dev/null 2>&1
rc=$?
case $rc in
  0|100|200) echo "Upgraded system";;
  *)         echo "Failed up upgrade system"; exit 1;;
esac



reply via email to

[Prev in Thread] Current Thread [Next in Thread]