tech-userlevel archive

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

Re: bin/39002: harmful AWK extension: non-portable escaped character



On Fri, Jun 20, 2008 at 05:41:06PM -0700, James Chacon wrote:
> Based on that (plus the regex section) I still think anything beyond the 
> the base escapes is undefined territory and even your examples show 
> different awks do different things.

I only just found this thread, after already airing my opinion in the
PR:

 On Fri, Jun 20, 2008 at 09:35:01PM +0000, Greg A. Woods; Planix, Inc. wrote:
  >  Gawk is sometimes a noisy pain in the butt.  :-)
  >  
  >  It is long standing tradition in Unix tools and languages to ignore  
  >  the backslash on non-special characters, right from C on up.
 
 Ordinarily, I'd agree, but in this case I think it's right to warn
 about it.
 
 In awk one often stuffs regexps into string constants, and it's easy
 to forget that if you're trying to escape something *in the regexp*
 you need to write two backslashes. Then one ends up with expressions
 like (foo ~ "\.c$") that superficially look ok but silently do the
 wrong thing. This is doubtless why mawk behaves the way it's reported
 to, but I don't think adopting that behavior is a good idea.


I think we should warn.

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index