Module Name: src Committed By: rillig Date: Sun Oct 4 08:02:17 UTC 2020
Modified Files: src/usr.bin/make/unit-tests: var-op-sunsh.mk Log Message: make(1): test another edge case for the :sh assignment To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-op-sunsh.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/unit-tests/var-op-sunsh.mk diff -u src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.2 src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.3 --- src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.2 Sun Oct 4 07:49:45 2020 +++ src/usr.bin/make/unit-tests/var-op-sunsh.mk Sun Oct 4 08:02:17 2020 @@ -1,4 +1,4 @@ -# $NetBSD: var-op-sunsh.mk,v 1.2 2020/10/04 07:49:45 rillig Exp $ +# $NetBSD: var-op-sunsh.mk,v 1.3 2020/10/04 08:02:17 rillig Exp $ # # Tests for the :sh= variable assignment operator, which runs its right-hand # side through the shell. It is a seldom-used alternative to the != @@ -71,5 +71,23 @@ VAR.key:shift= Shift . error .endif +# Just for fun: The code in Parse_IsVar allows for multiple appearances of +# the ':sh' assignment operator modifier. Let's see what happens ... +# +# Well, the end result is correct but the way until there is rather +# adventurous. This only works because the parser replaces each an every +# whitespace character that is not nested with '\0' (see Parse_DoVar). +# The variable name therefore ends before the first ':sh', and the last +# ':sh' turns the assignment operator into the shell command evaluation. +# Parse_DoVar completely trusts Parse_IsVar to properly verify the syntax. +# +# The ':sh' is the only word that may occur between the variable name and +# the assignment operator. All other words would lead to a parse error +# since the left-hand side of an assignment must be exactly one word. +VAR :sh :sh :sh :sh= echo multiple +.if ${VAR} != "multiple" +. error +.endif + all: @:;