|
From: | Samy Mahmoudi |
Subject: | Re: [bug-gawk] [PATCH] gawk: Comply with IEEE Std 1003.1 |
Date: | Wed, 15 Aug 2018 19:30:07 +0200 |
Hi.
> $ nawk -v x='abc\
> > def' 'BEGIN { print x }'
> abc
> def
> ----> Does this mean nawk does not fully comply with the standard ?
Yes. nawk was written before the standard was. It's behavior is
different from gawk's. I don't intend to change gawk's though.
> What I have not noticed before submitting the patch, is that both nawk
> and gawk behaved differently depending on quoting type.
This is an issue with the shell, not nawk/gawk. The shell removes the
\-newline combination inside double quotes (along with much other
processing). nawk/gawk never see the backslash or the newline.
Characters inside single quotes are left TOTALLY ALONE so nawk/gawk sees
the backslash and the newline.
> $ gawk (--posix|--traditional|<nothing>) -v x='abc\
> > def' 'BEGIN {print x}'
> abc\def
I changed gawk to remove the \ in this case. That was a (small) bug.
> $ gawk (--posix|--traditional|<nothing>) -v x="abc\
> >
> > def" 'BEGIN {print x}'
> abc
> def
The first newline is ignored since the shell removes it. The second
one is literally there, since it's inside a quoted string. Gawk
takes it as-is. After my changes, with --posix only, gawk will
issue an error.
Hope this helps,
Arnold
[Prev in Thread] | Current Thread | [Next in Thread] |