bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] Awk gets stucked if no filename


From: Eric Pruitt
Subject: Re: [bug-gawk] Awk gets stucked if no filename
Date: Wed, 29 Nov 2017 05:20:19 -0800
User-agent: NeoMutt/20170113 (1.7.2)

On Wed, Nov 29, 2017 at 01:38:33PM +0100, Xavier Martínez Serrano wrote:
> 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)".

Unless your shell uses variables in a non-POSIX manner, you're not
passing a file to Vim; since "$f" is an empty string, `awk
'{print("hi")}' $f` is the same as `awk '{print("hi")}'`. When no file
is explicitly given, AWK reads from standard input which happens to be
the terminal in this case. If you type some text then press Ctrl+D, you
should see "hi" printed.

Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]