[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gensub disagrees with its sub-gsub equivalent
From: |
Miguel Pineiro Jr. |
Subject: |
gensub disagrees with its sub-gsub equivalent |
Date: |
Fri, 06 Oct 2023 23:56:37 -0400 |
User-agent: |
Cyrus-JMAP/3.9.0-alpha0-958-g1b1b911df8-fm-20230927.002-g1b1b911d |
Hello Arnold and Co.,
gawk's gensub disagrees with its corresponding sub/gsub. Perhaps
an unintentional application of the regular expression escape
sequence rule which discards backslashes that don't introduce a
valid sequence?
BEGIN {
s = "aa"
print gensub(/a/, "\\x", 1, s)
sub(/a/, "\\x", s)
print s
s = "aa"
print gensub(/a/, "\\x", "g", s)
gsub(/a/, "\\x", s)
print s
}
I tested with an unmodified version of the current master branch:
* master 8e8b8cf2 A few more in xhe.po.
gawk output:
xa
\xa
xx
\x\x
BSD branch of onetrueawk and busybox:
\xa
\xa
\x\x
\x\x
I hope everyone is well,
Miguel
- gensub disagrees with its sub-gsub equivalent,
Miguel Pineiro Jr. <=