[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
How to set $?
From: |
Jeffrey Walton |
Subject: |
How to set $? |
Date: |
Sat, 25 Dec 2021 15:34:46 -0500 |
Hi Everyone,
I have a script that executes two sets of commands. If the first set
fails, I want to return the error code of the first set. For example:
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y
saved_result="$?"
apt-get autoremove --purge -y && apt-get autoclean -y
$?="$saved_result"
How do I set $?
- How to set $?,
Jeffrey Walton <=