[Top][All Lists]

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

bug: Inconsistancy in the use of double backslash

From: Paul Sorensen
Subject: bug: Inconsistancy in the use of double backslash
Date: Fri, 22 Apr 2005 11:00:07 +0000

This applies to version 3.1.3 and 3.1.4 of gawk on Linux.

I noticed some inconistancies in the use of backslash to escape the
backslash. Here is an example:

echo '\n' | gawk '{gsub("\\n","x",$0);print $0}'

One would expect the \n (lteral, not newline) to be replaced by x,
however; gsub fails to perform the substitution. You still get \n.

Similarly, sub and match fail to match any pattern that includes
a double backslash.

However, the following line:
echo '\n' | gawk '/\\n/ {print "found"}'
Prints found as expected.

Also the line:
/[\\]n/ {print "found"}
Works as expected.

However the line:
echo '\n' | gawk '{gsub("[\\]n","x",$0);print $0}'
Causes gawk to become confused and tries to escape the ] character.

I have used gawk regularly for many years and this is the first bug
I've seen. Keep up the good work.


reply via email to

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