Bug 217553

Summary: [patch] awk(1) assignment arguments do not accept values with a leading '='
Product: Base System Reporter: kd-dev
Component: binAssignee: Warner Losh <imp>
Status: Closed FIXED    
Severity: Affects Some People CC: cem
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Remove the second '=' check in `isclvar'. none

Description kd-dev 2017-03-05 01:39:26 UTC
Created attachment 180522 [details]
Remove the second '=' check in `isclvar'.

awk(1) explicitly disallows command-line assignments where the
assignment value has a leading '='.  This behavior is contrary to the
standard, which places no such restriction on assignment values.

From the standard:
	The characters following the <equals-sign> shall be interpreted
	as if they appeared in the awk program preceded and followed by
	a double-quote ('"') character, as a STRING token (see Grammar),
	except that if the last character is an unescaped <backslash>,
	it shall be interpreted as a literal <backslash> rather than as
	the first character of the sequence "\"".


How to reproduce:

	$ awk 'END{print var}' var='=value=' < /dev/null
	awk: can't open file var==value=
	 source line number 1

Expected output:
	=value=


	$ awk -v var='=value=' 'BEGIN{print var}'
	awk: invalid -v option argument: var== text

Expected output:
	=value=
Comment 1 Pedro F. Giffuni freebsd_committer freebsd_triage 2017-10-08 04:09:18 UTC
Warner was interested in awk.
Comment 2 Warner Losh freebsd_committer freebsd_triage 2019-06-03 06:18:17 UTC
The latest import of upstream nawk fixes this.