[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to get an error in piped getline?
From: |
Wolfgang Laun |
Subject: |
Re: How to get an error in piped getline? |
Date: |
Sun, 27 Feb 2022 09:29:35 +0100 |
One might test the existence (and other properties) of the file using
system() and use getline on the pipe only if it looks safe:
exit_code = system( "test -r noexist.gz " );
-W
On Sat, 26 Feb 2022 at 05:33, Peng Yu <pengyu.ut@gmail.com> wrote:
> $ awk -e 'BEGIN { exit_code = "zcat noexist.gz" | getline; print
> exit_code, "|" $0 "|"}'
> gzip: noexist.gz: No such file or directory
> 0 ||
>
> https://www.gnu.org/software/gawk/manual/html_node/Getline_002fPipe.html
>
> It is not clear how the error in a pipe is supposed to be dealt with
> in awk. Is there a way to get the error in the external program called
> in the pipe? Thanks.
>
> --
> Regards,
> Peng
>
>
--
Wolfgang Laun