bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] [PATCH] gawk: Comply with IEEE Std 1003.1


From: arnold
Subject: Re: [bug-gawk] [PATCH] gawk: Comply with IEEE Std 1003.1
Date: Tue, 31 Jul 2018 07:12:04 -0600
User-agent: Heirloom mailx 12.4 7/29/08

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]