bug-bash
[Top][All Lists]
Advanced

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

Re: return exit code in EXIT trap


From: Robert Elz
Subject: Re: return exit code in EXIT trap
Date: Tue, 09 Aug 2022 03:38:35 +0700

    Date:        Mon, 8 Aug 2022 15:16:41 -0400
    From:        "Robert E. Griffith" <bobg@junga.com>
    Message-ID:  <887ca26e-1c9e-f500-1bd9-6d339ab5adf8@junga.com>

  | I think a better solution to that would have been to leave return alone 
  | and instead allow the trap to access the $? value of the last command 
  | before the interruption in the first command of the trap string similar 
  | to how the ERROR trap works. (or in a new special var if that is 
  | problematic for some reason).

There's no need for anything to make that work, when the trap action
starts running $? is set to whatever it was just previously, and the
code there can save and/or use that value however it sees the need.

The issue (really the only issue related to $?) should be what value
it has when the trap action ceases running.   While it is running we
just have sh code, which should execute identically to what it would
were it not in a trap action.

kre




reply via email to

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