]> git.draconx.ca Git - dxcommon.git/commitdiff
Rework backslash substitutions in awk scripts.
authorNick Bowler <nbowler@draconx.ca>
Sun, 3 Dec 2023 04:13:24 +0000 (23:13 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sun, 3 Dec 2023 06:07:51 +0000 (01:07 -0500)
It appears that even using plain "\\" in a replacement string for sub
and gsub is still problematic.  Most awks handle this OK (returning a
literal backslash) provided the next character is not a backslash, but
on ULTRIX 4.5 nawk eats the next character regardless and interprets
it as a backslash-escape sequence, oops.

So let's try something a bit different.  We can ask awk what it does
with "\\\\", and use either "\\\\" or "\\" depending on the answer.

Hopefully this actually works everywhere.


No differences found