Subject: Re: problem with NetBSD awk
To: None <>
From: Jaromir Dolecek <>
List: tech-userlevel
Date: 04/22/2006 21:11:45
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Apr 22, 2006 at 09:42:27PM +0300, Aleksey Cheusov wrote:
>  >> 0 ~>/usr/bin/awk -v nls=3D"`printf 'a\nb\n'`" 'BEGIN { print nls }'
>  >> /usr/bin/awk: newline in string a
>  >> b... at source line 1
>  >> 2 ~>
>  >>=20
>  >> All three awk implementation works the same way with the following co=
>  >> /usr/bin/awk -v nls=3D'a\nb\n' 'BEGIN { print nls }'
>  >>=20
>  >> susv3 says the following
> > The fact that the second version works is normal,
> Agree. This case is just easier to explain ;)
> > since in susv3 (IMHO
> > you didn't quote the relevant part :
> My quote was correct but incomplete.
> My question was _NOT_ about -v a=3D"a\nb\n"
> > So, regarding NetBSD version of awk (nawk), it is posix compliant one
> > (regarding this) while others seem not.
> Very strange conslusion.

susv3 appears to say the string cannot contain unescaped newline
character. When using awk -v "`printf 'a\n'`" you are doing exactly
that (passing unescaped newline in string).

What nawk appears to be doing is that it handles -v nls=3Dfoo
~same as BEGIN { nls =3D "foo" }. Try:

gawk 'BEGIN { nls =3D "'"`printf 'a\nb'`"'}'

That gives error. The difference is that nawk uses same
rule for -v, while gawk and mawk handles -v assignment

So I'd say awk (actually nawk) behaviour is just fine and
in-line with the standard.

Jaromir Dolecek <>  
-=3D- We can walk our road together if our goals are all the same;     -=3D-
-=3D- We can run alone and free if we pursue a different aim.          -=3D-

Content-Type: application/pgp-signature
Content-Disposition: inline

Version: PGPfreeware 5.0i for non-commercial use
MessageID: ryhtQ4dT3VcrnLSPA3i/d6gm5ff32Q6o