bug-gawk
[Top][All Lists]
Advanced

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

Is there a way to add a rule without blocking?


From: Peng Yu
Subject: Is there a way to add a rule without blocking?
Date: Tue, 17 Mar 2020 12:49:09 -0500

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]