Received: by mail.netbsd.org (Postfix, from userid 605) id 3520984D7E; Sun, 14 Mar 2021 18:02:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 67F2384D6D for ; Sun, 14 Mar 2021 18:02:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id byP3WGP5FVtd for ; Sun, 14 Mar 2021 18:02:44 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id ACF4784D6C for ; Sun, 14 Mar 2021 18:02:44 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 9E1C1FA95; Sun, 14 Mar 2021 18:02:44 +0000 (UTC) Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" MIME-Version: 1.0 Date: Sun, 14 Mar 2021 18:02:44 +0000 From: "Roland Illig" Subject: CVS commit: src/usr.bin/make To: source-changes@NetBSD.org X-Mailer: log_accum Message-Id: <20210314180244.9E1C1FA95@cvs.NetBSD.org> Sender: source-changes-owner@NetBSD.org List-Id: Precedence: bulk Reply-To: source-changes-d@NetBSD.org Mail-Reply-To: "Roland Illig" Mail-Followup-To: source-changes-d@NetBSD.org List-Unsubscribe: Module Name: src Committed By: rillig Date: Sun Mar 14 18:02:44 UTC 2021 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: var-eval-short.exp Log Message: make: only evaluate the ':@' modifier if the result is actually used The test 'var-eval-short' had produced the output 'unexpected' before, on stderr. It had been generated by '${:Uword:@${FAIL}@expr@}' by combining the following obscure "features" of make: 1. the ':@' modifier loops over the words of the variable. This modifier is not really obscure, it still takes some time to get used to it. 2. the ':@' modifier allows a '$' sign in the variable name, which is useless in practice. 3. the ':@' modifier creates a temporary loop variable in the global namespace. Luckily there are only few collisions with other variable names since their naming conventions differ. 4. after looping over the words of the expression, the temporary global loop variable is deleted, and at that point the '$' is expanded, being interpreted as the start of a variable expression. 5. The ':@' modifier deleted the global variable even when it was called in parse-only mode (without VARE_WANTRES). When the modifier ':@' was initially added to make in var.c 1.40 from 2000-04-29, Var_Delete didn't expand the variable name. That feature was added in var.c 1.174 from 2013-05-18, probably without thinking of this very edge-casey combination of features. This commit fixes item 5 from the above list. The other obscurities remain for now. To generate a diff of this commit: cvs rdiff -u -r1.869 -r1.870 src/usr.bin/make/var.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-eval-short.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.