Article View: comp.bugs.sys5
Article #407nawk sub/gsub bug
From: Eric Gisin
Date: Fri, 10 May 1991 17:55
Date: Fri, 10 May 1991 17:55
14 lines
747 bytes
747 bytes
$ uname -r
3.2
$ echo .xx. | sed 's/xx*/\\&\\/'
.\xx\.
# note that "\\" passes a single \ to sub.
$ echo .xx. | nawk '{sub(/x+/,"\\&\\"; print}'
.&\.
$ echo .xx. | nawk '{sub(/x+/,"\\\\&\\\\"; print}'
.\&\\.
I don't know whether its a feature or a bug, but you can't use sub
to enclose a substring with \'s, as the sed example does.
The sub/gsub algorithm should be modified to replace \& with &,
\\ with \, and leave all other escapes alone.
Technical Details
Message-ID:
<1991May10.175555.10306@mks.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!mks.com!ericShow Full Headers
Complete Article Headers
Newsgroups: comp.bugs.sys5 Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!mks.com!eric From: eric@mks.com (Eric Gisin) Subject: nawk sub/gsub bug Organization: Mortice Kern Systems Inc., Waterloo, Ontario, CANADA Date: Fri, 10 May 91 17:55:55 GMT Message-ID: <1991May10.175555.10306@mks.com>