[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to get an error in piped getline?
From: |
david kerns |
Subject: |
Re: How to get an error in piped getline? |
Date: |
Fri, 25 Feb 2022 23:18:48 -0700 |
$ gawk 'BEGIN{c="echo 3;false";c|getline x;r=close(c);print x,r}'
3 1
On Fri, Feb 25, 2022 at 9:33 PM 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
>
>