bug-bash
[Top][All Lists]
Advanced

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

Re: Some minor notes on manual chapter 4 "Shell Builtin Commands"


From: Kerin Millar
Subject: Re: Some minor notes on manual chapter 4 "Shell Builtin Commands"
Date: Mon, 9 Oct 2023 06:57:23 +0100

On Mon, 9 Oct 2023 01:16:41 +0200
Martin Schulte <gnu@schrader-schulte.de> wrote:

> Hello,
> 
> I took a closer look on the online manual chapter 4 "Shell Builtin Commands" 
> and found some inconsistencies:
> 
> - true and false seem to be missing (in 4.1 Bourne Shell Builtins).
> 
> The following has been tested with bash 5.2.15:
> 
> - 3.7.5 Exit Status says: "All builtins return an exit status of 2 to 
> indicate incorrect usage, generally invalid options or missing arguments." 
> but cd with two or more non-optional arguments returns an exit status of 1.
> 
> - The same is true if exit is called with two or more argument where the 
> first is numeric. This exit doesn't terminate bash.
> 
> - When exit is invoked with a non-numeric first argument it terminates bash. 
> That seems to be inconsistent with the behaviour described before, while the 
> exit status of the shell is 2 and consistent in some way.

Just to add that, while POSIX does not specify the behaviour of the exit 
builtin where its operand "is not an unsigned decimal integer or is greater 
than 255", it does forbid all special built-in utilities (including exit) from 
causing an interactive shell to exit on account of an error. So, for an 
interactive instance of bash to raise a "numeric argument required" error then 
proceed to exit seems contrary to the specification.

Taking dash as a counter-example, its behaviour fulfils the requirements laid 
out by 2.8.1 Consequences of Shell Errors for both interactive and 
non-interactive instances.

$ exec dash
$ exit foo
dash: 1: exit: Illegal number: foo
$ echo $?
2
$ printf %s\\n 'exit foo' 'echo done' | dash
dash: 1: exit: Illegal number: foo
$ echo $?
2

-- 
Kerin Millar



reply via email to

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