help-bash
[Top][All Lists]
Advanced

[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 $?



reply via email to

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