[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Awk gets stucked if no filename
From: |
arnold |
Subject: |
Re: [bug-gawk] Awk gets stucked if no filename |
Date: |
Wed, 29 Nov 2017 06:28:01 -0700 |
User-agent: |
Heirloom mailx 12.4 7/29/08 |
Hello.
Thank you for submitting a bug report.
Your understanding below is incorrect. When no filenames are named on
the command line, awk reads from standard input. This is documented and
has been awk's behavior ever since it existed.
You can work around this in your script with something like
awk '{print("hi")}' $f /dev/null
Or be more careful to check $f before invoking awk, etc.
HTH,
Arnold
Xavier MartÃnez Serrano <address@hidden> wrote:
> Hi,
>
> I'm not sure whether this is a bug or not, but at least is not the
> behaviour from standard Linux commands. If I add a pattern code but no
> filename to parse, awk gets stucked waiting:
>
> f=""
> $ awk '{print("hi")}' $f
> ... <neverending wait>
>
> This is a problem when awk is used within shell scripts where the filename
> is supplied via a shell var. In case the filename is empty, the shellscript
> never ends.
>
> To my understanding if awk cant find the file should issue an "exit(1)".
>
> Many thanks in advance, greetings,
> Xavi