[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Potential awk bug in comment line with combination # and
From: |
Aharon Robbins |
Subject: |
Re: [bug-gawk] Potential awk bug in comment line with combination # and ' characters. |
Date: |
Mon, 25 Jun 2012 21:36:43 +0300 |
User-agent: |
Heirloom mailx 12.4 7/29/08 |
Hello. Re the below.
You are running into shell quoting issues and not awk issues. When you
have a script of the form:
awk 'line 1 ...
line 2 ...
....
line N' data
The single quotes enclose the entire program, including the embedded
newlines, and turn it into a single argument.
Single quotes don't provide any mechansims for embedded single quotes. So
if you have
awk '.....
# '|' ...'
You actually have two commands separated by a shell pipe. The way to
verify this is to put the suspect program into a separate file, without the
leading and closing quotes, and run the file with awk -f prog.awk. I
suspect that you will then get the behavior you expect.
Thanks,
Arnold
P.S. The current version of gawk is 4.0.1; you should upgrade, or get
your GNU/Linux vendor to do so. Thanks.
> From: Dave <address@hidden>
> To: address@hidden
> Date: Sun, 24 Jun 2012 10:54:02 -0400
>
> TO: address@hidden
>
> From David M. Boulin
> address@hidden
> Date: 6-24-2012
>
> Summary of suspected COMMENT LINE awk bug:
> 1) Combinations with # followed by one or more "'" give errors or
> unpredictable
> results as shown below. These include # ' and # '|' , etc.
>
> 2) Note:from "info awk": Definition of a comment:
> Comments begin with the ???#??? character, and
> continue
> until the end of the line.
> As far a I can tell there are no stated exemptions
> on what characters can be used in a comment line.
> ===============================================================================
> OS: Linux 3.0.0-21-generic (i686)
> awk version: GNU Awk 3.1.8
> C compiler: GNU C Compiler version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
> Distribution: Ubuntu 11.10
> value of LC_ALL= null initially
> value of LC_ALL= C No change to results posted below after setting this
> and
> re-executing the awk script file..
> ===============================================================================
>
>
>
> ===============================================================================
> The AWK program is in a file called 'testit' which is executable
> (-rwxrw-r--):
> It's contents followd:
> awk '
> # Prog testit to demo a bug. Change comment line below and see NOTES for
> results:
> #
> { print "Hello World" }
> ' datafile
>
> ===============================================================================
>
>
> ===============================================================================
> Contents of the datafile:
> $ cat datafile
> LineFromDataFile
> $
> ===============================================================================
>
>
> ===============================================================================
> By changing the 3rd line which initial consisting only of a pound sign
> # to
> the following list of string examples, then execute via ./testit, you
> will get the results shown (some spaced deleted in error line for
> brevity).
>
> Content of
> third line: Results Comment
> --------- ------- -------
> # Hi Hello World As expected
> # " " Hello World As expected
>
> #Use '|' blabla ./testit:line 5:$' blabla\n\t{ print "Hello World" }\n':
> command not found
> # '|' ./testit: line 5: $'\n\t{ print "Hello World" }\n ':
> command not found
> # ' ./testit: line 8: syntax error: unexpected end of file
> # ' ' No output - no reported errors
> # 'x' Hello World - no reported errors
> ===============================================================================
>
> From "info awk" page:
> BUG REPORTS
> If you find a bug in gawk, please send electronic mail
> to
> address@hidden
>
> Hope this has been of some help.
> I look forward to your reply,
> Dave