From: Mark Borges <mdb@cdc.noaa.gov>
To: ZSH mailing list <zsh-workers@math.gatech.edu>
Cc: Zoltan Hidvegi <hzoli@cs.elte.hu>
Subject: [zsh-2.6-b18] signames.awk and the backslash treatment bug
Date: Wed, 22 May 1996 13:53:13 -0600 [thread overview]
Message-ID: <9605221953.AA08239@suomi.cdc.noaa.gov> (raw)
I wrote the author of mawk, Michael Brennan, concerning the behavior
of mawk w.r.t. the backslashes introduced into the signames.awk script
in beta18. Appended is his take on the matter.
This is probably more than anyone ever wanted to know, but in case you
are curious...
------- start of forwarded message (RFC 934 encapsulation) -------
Content-Type: text
content-length: 891
From: brennan@amc.com (Michael Brennan)
Subject: Re: [mawk-1.2.2] backslash treatment
Date: Wed, 22 May 1996 12:36:00 -0700 (PDT)
To: mdb@cdc.noaa.gov (Mark Borges)
>
> Is this a bug in mawk?
>
> Apparently the use of a `\' preceding a character that need not be
> escaped in a print statement is ambiguous. Some awks remove it, others
> (like mawk) leave it verbatim.
>
The posix answer is "\z" has undefined meaning which implies that it is
not portable to use it. The posix standard says it is explicitly
undefined. Note that the same thing is true for ansi C. See K&R
(ansi version) page 193.
I discuss this issue in the portability section of the mawk man pages
(near the back).
[man page excerpt]
With mawk, the following are all equivalent,
x ~ /a\+b/ x ~ "a\+b" x ~ "a\\+b"
The strings get scanned twice, once as string and once as
regular expression. On the string scan, mawk ignores the
escape on non-escape characters while the AWK book advocates
\c be recognized as c which necessitates the double escaping
of meta-characters in strings. Posix explicitly declines to
define the behavior which passively forces programs that
must run under a variety of awks to use the more portable
but less readable, double escape.
[end man page excerpt]
In mawk, I wanted
x ~ /c\+/
x ~ "c\+"
to work the same. Note with nawk or gawk, you need to
x ~ "c\\+"
to escape + once for the string scan and once for the regexp scan.
With mawk
x ~ "c\\+"
works correctly too.
- --
Mike
brennan@amc.com
------- end -------
next reply other threads:[~1996-05-22 20:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-05-22 19:53 Mark Borges [this message]
1996-05-22 21:16 ` Johan Danielsson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9605221953.AA08239@suomi.cdc.noaa.gov \
--to=mdb@cdc.noaa.gov \
--cc=hzoli@cs.elte.hu \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).