[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gawk] Possible gawk Bug--Handling of --source Option
From: |
Neil R. Ormos |
Subject: |
[bug-gawk] Possible gawk Bug--Handling of --source Option |
Date: |
Thu, 13 Apr 2017 14:58:02 -0500 (CDT) |
I have a question about a behavior of gawk 4.1.1 which differs from that in
3.1.7. I'm not sure if it's a bug.
The possible bug relates how gawk handles program text provided on the command
line in an argument to a --source= option.
Older gawk (e.g. 3.1.7) appears to allow the statements of a single action to
be distributed among several --source= arguments that appear on the command
line invoking gawk.
The gawk in Debian Stable (e.g. 4.1.1) appears to require that any action
opened in a --source= argument be closed in the same argument, so that an
action cannot span multple --source= arguments.
As far as I can tell, the the GNU Awk User's Guide does not directly specify
either the new or the old behavior. However, the manual's section directed to
the igawk shell-wrapper script [*], that provides a mechanism for including
files but otherwise appears to be intended to simulate invoking gawk the
ordinary way, characterizes the wrapper script's handling of a --source
argument as, "The source text is appended to program".
[*] http://www.gnu.org/software/gawk/manual/gawk.html#Igawk-Program
############################################################
### OLD ###
> lsb_release -d
Description: Debian GNU/Linux 6.0.10 (squeeze)
> gawk --version
GNU Awk 3.1.7
[...]
> gawk --source='BEGIN{a=5};' --source='BEGIN{print a}'
5
> gawk --source='BEGIN{a=5; ' --source='print a}'
5
############################################################
### NEW ###
> lsb_release -d
Description: Debian GNU/Linux 8.7 (jessie)
> gawk --version
GNU Awk 4.1.1, API: 1.1 (GNU MPFR 3.1.2-p3, GNU MP 6.0.0)
[...]
> gawk --source='BEGIN{a=5};' --source='BEGIN{print a}'
5
> gawk --source='BEGIN{a=5; ' --source='print a}'
gawk: cmd. line:1: BEGIN{a=5;
gawk: cmd. line:1: ^ unexpected newline or end of string
############################################################
This seems like a bug to me, but I don't know if the completeness of a --source
argument is specified more definitively somewhere other than in the User's
Guide.
Thanks for your help.
Best regards,
--Neil Ormos
- [bug-gawk] Possible gawk Bug--Handling of --source Option,
Neil R. Ormos <=