A NOTE has been added to this issue. 
====================================================================== 
http://austingroupbugs.net/view.php?id=1105 
====================================================================== 
Reported By:                stephane
Assigned To:                
====================================================================== 
Project:                    1003.1(2016)/Issue7+TC2
Issue ID:                   1105
Category:                   Shell and Utilities
Type:                       Enhancement Request
Severity:                   Editorial
Priority:                   normal
Status:                     New
Name:                       Stéphane Chazelas 
Organization:                
User Reference:              
Section:                    awk 
Page Number:                 
Line Number:                 
Interp Status:              --- 
Final Accepted Text:         
====================================================================== 
Date Submitted:             2016-12-05 21:52 UTC
Last Modified:              2018-04-30 12:00 UTC
====================================================================== 
Summary:                    problems with backslashes in awk strings and EREs
====================================================================== 

---------------------------------------------------------------------- 
 (0004018) stephane (reporter) - 2018-04-30 12:00
 http://austingroupbugs.net/view.php?id=1105#c4018 
---------------------------------------------------------------------- 
re: http://austingroupbugs.net/view.php?id=1105#c3999

Yes, I came across that recently as well (though I didn't find the POSIX
spec ambiguous then) at
https://unix.stackexchange.com/questions/439752/replace-pattern-each-time-with-a-different-string-taken-from-external-file/439754#439754

I had to be use

gsub(/[&\\]/, "\\\\&", repl)

to "escape" the & and \ characters in "repl" (so it can later be used
verbatim in another sub()), and for gawk, I had to enable the POSIX mode
for that "\\\\&" to mean a literal backslash followed by the matched
string. I noticed it didn't work in heirloom awk_su3 (presumably the same
as Solaris awk), I assumed a bug.

I agree that if  the spec is not already clear there, it would be worth
addressing as part of that same bug. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2016-12-05 21:52 stephane       New Issue                                    
2016-12-05 21:52 stephane       Name                      => Stéphane Chazelas
2016-12-05 21:52 stephane       Section                   => awk             
2018-04-25 22:27 McDutchie      Note Added: 0003999                          
2018-04-26 08:53 joerg          Note Added: 0004000                          
2018-04-30 09:59 geoffclare     Note Added: 0004014                          
2018-04-30 10:39 stephane       Note Added: 0004015                          
2018-04-30 11:06 McDutchie      Note Added: 0004016                          
2018-04-30 11:26 geoffclare     Note Added: 0004017                          
2018-04-30 12:00 stephane       Note Added: 0004018                          
======================================================================


Reply via email to