bug-bash
[Top][All Lists]
Advanced

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

Re: local failure


From: Laurent Picquet
Subject: Re: local failure
Date: Sat, 30 May 2020 15:33:20 +0100

Hello Dale,

This is really interesting.
Should the 'local' command be the one able to detect that the assignment to
the variable had an non-zero exit code and return the non-zero exit code?

as a developer, it is counter-intuitive that the 'local' command tells us
everything is ok when it wasn't. If feel it should know that the assignment
encountered a problem and should report it

The return status is zero unless local is used outside a function, an
invalid name is supplied, or name is a readonly variable.



On Fri, 29 May 2020 at 03:43, Dale R. Worley <worley@alum.mit.edu> wrote:

> It's a subtle point.  See this paragraph in the bash manual page:
>
>        If there is a command name left after expansion, execution
>        proceeds as described below.  Otherwise, the command exits.  If
>        one of the expansions contained a command substitution, the exit
>        status of the command is the exit status of the last command
>        substitution performed.  If there were no command substitutions,
>        the command exits with a status of zero.
>
> In one of your examples, a "local" command is generated using a command
> substitution, so the exit status is that of the local command.  In the
> other, only an assignment is done, which is not a command, so the exit
> status is that of the last command substitution.
>
> Dale
>


-- 


-- 

Laurent Picquet

16, Hunters Chase

South Godstone

RH98HR

England

tel: 07882 356 104


reply via email to

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