From 3c5b4335d36d2aaa5dadc82b004f43e5a18eddfa Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 18 Oct 2022 15:02:44 +0100 Subject: make: shell assignment is a POSIX 202X feature Austin Group defect report 337 has been accepted, thus making macro assignment from the output of a shell command (!=) a POSIX 202X feature. This was previously implemented as a non-POSIX extension. --- miscutils/make.c | 9 ++++----- testsuite/make.tests | 23 ++++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/miscutils/make.c b/miscutils/make.c index 8e3778461..431ac41d4 100644 --- a/miscutils/make.c +++ b/miscutils/make.c @@ -1609,11 +1609,11 @@ input(FILE *fd, int ilevel) } break; } - case '!': - // ':=' and '!=' are non-POSIX extensions. + // ':=' is a non-POSIX extension. case '+': case '?': - // '+=' and '?=' are from POSIX 202X. + case '!': + // '+=', '?=' and '!=' are from POSIX 202X. if (posix) break; eq = q[-1]; @@ -1662,8 +1662,7 @@ input(FILE *fd, int ilevel) if (rhs != q) free(rhs); q = newq; - } - else if (eq == '!') { + } else if (eq == '!') { char *cmd = expand_macros(q, FALSE); q = newq = run_command(cmd); free(cmd); diff --git a/testsuite/make.tests b/testsuite/make.tests index 67617f8a2..c97950e95 100755 --- a/testsuite/make.tests +++ b/testsuite/make.tests @@ -267,6 +267,18 @@ target: file1 file2 file2 file3 file3 ' cd .. || exit 1; rm -rf make.tempdir 2>/dev/null +# Assign the output of a shell command to a macro. +testing "make shell assignment" \ + "make -f -" \ + "1 2 3 4\n" "" ' +hello != echo 1; echo 2; echo 3; echo; echo + +target: + @echo "$(hello) 4" +' + +cd .. || exit 1; rm -rf make.tempdir 2>/dev/null + # Nested macro expansion is allowed. This should be compatible # with other implementations. testing "make nested macro expansion" \ @@ -332,17 +344,6 @@ testing "make chained inference rules" \ ' cd .. || exit 1; rm -rf make.tempdir 2>/dev/null -# Assign the output of a shell command to a macro. -testing "make shell assignment" \ - "make -f -" \ - "1 2 3 4\n" "" ' -hello != echo 1; echo 2; echo 3; echo; echo - -target: - @echo "$(hello) 4" -' - -cd .. || exit 1; rm -rf make.tempdir 2>/dev/null # make supports *, ? and [] wildcards in targets and prerequisites mkdir make.tempdir && cd make.tempdir || exit 1 touch -t 202206171201 t1a t2aa t3b -- cgit v1.2.3-55-g6feb