bug-bash
[Top][All Lists]
Advanced

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

Re: value of $? and exit status are partially undocumented, possibly wro


From: Vincent Lefevre
Subject: Re: value of $? and exit status are partially undocumented, possibly wrong
Date: Tue, 17 Oct 2023 23:59:04 +0200
User-agent: Mutt/2.2.12+67 (757ca3b3) vl-149028 (2023-09-09)

On 2023-10-17 10:16:35 -0400, Chet Ramey wrote:
> On 10/13/23 9:18 AM, Vincent Lefevre wrote:
> > The difference seems to be due to the exit status of the last command
> > of the .bashrc file. But this is undocumented.
> 
> How so? The exit status ($?) is the status of "the last command executed,"
> and an interactive non-login shell "reads and executes commands from
> ~/.bashrc."

I still think that this would be worth clarifying.

> > Note that on the opposite, for a login shell, e.g. "bash -l", the
> > exit status of the last command of .bash_logout is ignored for the
> > exit status of bash. So this is confusing.
> 
> Think of it like the EXIT trap. If you run `exit 4', you don't want
> ~/.bash_logout changing that exit status.

Well, this is not obvious as this would still be under the control
of the user, who could restore $? at the end of ~/.bash_logout.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)



reply via email to

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