[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: no exit status available when a command doesn't exist or fails in pi
From: |
Ed Morton |
Subject: |
Re: no exit status available when a command doesn't exist or fails in pipe to grep |
Date: |
Thu, 9 Sep 2021 20:52:01 -0500 |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 |
On 9/9/2021 5:04 PM, Neil R. Ormos wrote:
Ed Morton wrote:
Neil R. Ormos wrote:
the notion that we somehow don't know what "if
the close was successful" means is a fiction.
We'll have to agree to disagree. If someone told
me to write a function foo() to release some
resource X and return success if foo() succeeded
my first question would be "what should it
return if X is already idle".
The inability to close() something because it was already closed or never opened in the
first place is recognized as an "error" and the value returned by close() is
-1. See the manual.
That's good that we agree it's an error but, since we're talking about
POSIX compliance, see the POSIX spec for the value returned by close()
(https://pubs.opengroup.org/onlinepubs/9699919799/utilities/awk.html#tag_20_06_13_14
under "Input/Output and General Functions"):
close(expression)
Close the file or pipe opened by a print or printf statement or
a call to getline with the same string-valued expression. The limit
on the number of open expression arguments is
implementation-defined. If the close was successful, the function
shall return zero; otherwise, it shall return non-zero.
It doesn't say close() will return -1 on an error, it says if the call
wasn't successful it'll return non-zero.
That is the "otherwise" condition in the POSIX spec.
As demonstrated earlier, a non-zero return code from some piped command (or the
shell) does not defeat the operation of close().
Reiterating: it's Arnold and Andy you have to convince.
I'm not trying to convince anyone, I made a suggestion they'll do
whatever they think makes sense. I'm just responding to your emails to
me about the subject, I was done with everything I had wanted to say
when Arnold said "I will think about it.". I am done now though.
Ed.
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, (continued)
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, arnold, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Neil R. Ormos, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Ed Morton, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Andrew J. Schorr, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Ed Morton, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Neil R. Ormos, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Ed Morton, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Neil R. Ormos, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Ed Morton, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Neil R. Ormos, 2021/09/09
- Re: no exit status available when a command doesn't exist or fails in pipe to grep,
Ed Morton <=
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, arnold, 2021/09/10
- Re: no exit status available when a command doesn't exist or fails in pipe to grep, Ed Morton, 2021/09/10