Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14786

Re: exiting noninteractive shells on 'shift 2'

From Eric Blake <eblake@redhat.com>
Newsgroups gnu.bash.bug
Subject Re: exiting noninteractive shells on 'shift 2'
Date 2018-11-09 10:22 -0600
Organization Red Hat, Inc.
Message-ID <mailman.3750.1541780586.1284.bug-bash@gnu.org> (permalink)
References <cd413815-9523-f280-3ef3-fcd21bf7119e@redhat.com> <d8601773-69c8-16d1-82ab-5068d63bb24d@case.edu> <9ced783a-1c2b-f2c8-2287-fc0f6b967fa8@redhat.com> <fbe5c62d-d633-2fa5-32d1-591ff41a23cc@case.edu>

Show all headers | View raw


On 11/9/18 8:52 AM, Chet Ramey wrote:
> On 11/9/18 9:47 AM, Eric Blake wrote:
> 
>> Well, there's STILL a conformance issue - the standard requires that unless
>> documented otherwise, any time a command line tool exits with non-zero
>> status, that it outputs a message to stderr explaining the error.
> 
> Where?
> 

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#shift

"STDERR

     The standard error shall be used only for diagnostic messages."

"CONSEQUENCES OF ERRORS

     Default."

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html

1.4 Utility Description Defaults:

STDERR

"Default Behavior: When this section is listed as "The standard error 
shall be used only for diagnostic messages.", it means that, unless 
otherwise stated, the diagnostic messages shall be sent to the standard 
error only when the exit status indicates that an error occurred and the 
utility is used as described by this volume of POSIX.1-2017."

CONSEQUENCES OF ERRORS

"The following shall apply to each utility, unless otherwise stated:

     If the requested action cannot be performed on an operand 
representing a file, directory, user, process, and so on, the utility 
shall issue a diagnostic message to standard error and continue 
processing the next operand in sequence, but the final exit status shall 
be returned as non-zero.

     For a utility that recursively traverses a file hierarchy (such as 
find or chown -R), if the requested action cannot be performed on a file 
or directory encountered in the hierarchy, the utility shall issue a 
diagnostic message to standard error and continue processing the 
remaining files in the hierarchy, but the final exit status shall be 
returned as non-zero.

     If the requested action characterized by an option or 
option-argument cannot be performed, the utility shall issue a 
diagnostic message to standard error and the exit status returned shall 
be non-zero.

     When an unrecoverable error condition is encountered, the utility 
shall exit with a non-zero exit status.

     A diagnostic message shall be written to standard error whenever an 
error condition occurs."

Since 'shift 2' when $# is 1 is an error, and results in non-zero 
status, it should print a diagnostic to stderr.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: exiting noninteractive shells on 'shift 2' Eric Blake <eblake@redhat.com> - 2018-11-09 10:22 -0600

csiph-web