bug-gawk
[Top][All Lists]
Advanced

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

Re: Is there a way to add a rule without blocking?


From: Wolfgang Laun
Subject: Re: Is there a way to add a rule without blocking?
Date: Tue, 17 Mar 2020 19:31:12 +0100

How would your mygawk ever be useful without additional rules? And as soon
you have additional rules, gawk will want to read some input file, which
you'll have to provide on the shell command.

-W

On Tue, 17 Mar 2020 at 18:49, Peng Yu <address@hidden> wrote:

> I want to create a shell alias of gawk with the following command initial.
>
> alias mygawk='gawk -e '\''!NF { NF=1 }'\'
>
> So that I can change the default of an empty line for NF to 1.
>
> $ mygawk -e '{ print NF }' <<< ''
> 1
> $ gawk -e '{ print NF }' <<< ''
> 0
>
> But it will block when no input is provided. Is there a way to get rid
> of the hang problem, yet still modify gawk so that NF will be set to 1
> by default for empty input lines.
>
> $ mygawk -e 'BEGIN { print "Hello World!" }' # This will hang.
> Hello World!
>
> $ gawk -e 'BEGIN { print "Hello World!" }' # This does not hang.
> Hello World!
>
> --
> Regards,
> Peng
>
>


reply via email to

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