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?

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Eli Schwartz <eschwartz@archlinux.org>
Newsgroups gnu.bash.bug
Subject Re: How to tell Bash multiple values are success?
Date Wed, 19 Jun 2019 11:14:37 -0400
Lines 99
Approved bug-bash@gnu.org
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>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="u7yYgnae4bPY2cVKX2kisIc78fL4fM78x"
X-Trace usenet.stanford.edu 1560957301 21838 209.51.188.17 (19 Jun 2019 15:15:01 GMT)
X-Complaints-To action@cs.stanford.edu
To bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/simple; d=archlinux.org; s=orion; t=1560957281; bh=vrX8cFKE466kXK1NXfLBcJh7U6RItrHkNKApO9oxZzc=; h=Subject:To:References:From:Date:In-Reply-To; b=n8a3VuhskELmvapMU6g8TFDQbzDOQx6Q3hdguVUq263MyQ1rAzZcg9hdaboZ0TK9o jBalgulQ/XOkYKjljLRDBt4KYlftrHNGpq8+Ahm2tzIn4A/FF6C7gdr7fYiml5uz+j mNrPi2asI47rupkQNQMjFBFTds1eLmLc/5IqQt49064bV+WEMd9E1gC0+XLCzXBs7l R5LcsDhVLVbJDlDQzvKX/PK+1v2+7kwnBMF/6NzHdCma1Rs+j9OEpvExsRqsfirbHb H15rNwBY5Dw5ap+hOL3Dja+OV6tK7WkEIoLshDQWGFLQ1DhGApvI897WD0cQ0eEoch MVyLlXP/ebYA3xJV4PzeJk5Ctpl7R6Mj5gu/GsLJdhKhO4ExlCL3rEdyw/69DXqzUK jKdIhEU5iVyvePiBL6pQ1YGArKy/+JlTA1nZIsHNiuYjZhefBwjwOqUgXttWrRMn7B zBk9It79DJBekPI4Sap7JtQ8Um+uzipvmCM69XIBt3O/2elkRhjdzCBYNWJsdNuo1t m62a9n3o1QPLeBvy8QTykRt+AS8r5uli6Nwx0jNz0YFeQ9GQ00J99T0GTWjEFEpR6C uq2q2e7UjqJF/jNm60yDxYIeV9RgA/tIkU09ZdFz1gIYTm0W60hXlZOtUH91vLxbC0 Ac46sDJ2yb4CmmXDGJ6b2zxE=
Openpgp preference=signencrypt
X-Clacks-Overhead GNU Terry Pratchett
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1
In-Reply-To <CAH8yC8nj-JmJH_C+=6EPy7JmgG7JsOyx973DdMF6kTpcVAcZRg@mail.gmail.com>
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From 88.198.91.70
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <fd8e53d9-1830-ec94-e94f-0877f28ce3a5@archlinux.org>
X-Mailman-Original-References <CAH8yC8nj-JmJH_C+=6EPy7JmgG7JsOyx973DdMF6kTpcVAcZRg@mail.gmail.com>
Xref csiph.com gnu.bash.bug:15063

Show key headers only | 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