[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: |
Andrew J. Schorr |
Subject: |
Re: no exit status available when a command doesn't exist or fails in pipe to grep |
Date: |
Thu, 9 Sep 2021 08:35:38 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Thu, Sep 09, 2021 at 01:58:59AM -0600, arnold@skeeve.com wrote:
> POSIX merely says that
>
> | 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.
>
> This is fairly vague. I think you're getting zero because the
> underlying pclose() (or equivalent code) succeeds, even thogh the
> command itself failed.
I could be confused, but the code in io.c:do_close() looks like it returns 0 in
POSIX mode unless the command was not found. At the end of the function, it
says:
tmp = make_number((AWKNUM) close_redir(rp, false, how));
rp = NULL;
/*
* POSIX says close() returns 0 on success, non-zero otherwise.
* For POSIX, at this point we just return 0. Otherwise we
* return the exit status of the process or of pclose(), depending.
* Down in the call tree of close_redir(), we rationalize the
* value like we do for system().
*/
if (do_posix) {
unref(tmp);
tmp = make_number((AWKNUM) 0);
}
return tmp;
So gawk forces the return code to 0 in POSIX mode in almost all cases.
Regards,
Andy
- no exit status available when a command doesn't exist or fails in pipe to grep, ED MORTON, 2021/09/06
- 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,
Andrew J. Schorr <=
- 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, Ed Morton, 2021/09/09
- 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