[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to set $?
From: |
Greg Wooledge |
Subject: |
Re: How to set $? |
Date: |
Sat, 25 Dec 2021 18:21:57 -0500 |
On Sun, Dec 26, 2021 at 09:40:34AM +1100, David wrote:
> Should be:
> apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
> saved_result=$?
> apt-get autoremove --purge -y && apt-get autoclean -y
> exit "$saved_result"
Ah, I should have read the original question more closely.
The LITERAL question that was asked was "how to set $?" which I answered
in a very straightforward way.
But the ACTUAL question should have been "how do I set the exit status of
my script when exiting", which you have answered here.