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 Jun 22, 2008, at 10:40 AM, Aleksey Cheusov wrote:

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.

Also see standards/38127 and my another mail in this mailing list.
The problem there is close to this one.

I'm not necessarily apposed to warning, just that changing our existing behavior of what to do with them should remain the same.

i.e. it's undefined behavior and there's clearly no "standard behavior" per se.


Home | Main Index | Thread Index | Old Index