Subject: Re: make(1) question; purpose of ${ :? : }
To: Luke Mewburn <lukem@NetBSD.org>
From: Simon Gerraty <sjg@juniper.net>
List: tech-toolchain
Date: 01/08/2004 16:08:24
Ok with the patch below the test case:

all:
	@echo "The answer is ${A:?known:unknown}"
	@echo "The answer is ${A:?$A:unknown}"
	@echo "The answer is ${empty(A):?empty:$A}"

works as expected:

$ ./bmake -f /homes/sjg/make-tests/ternary
The answer is unknown
The answer is unknown
The answer is empty
$ ./bmake -f /homes/sjg/make-tests/ternary A=
The answer is known
The answer is
The answer is empty
$ ./bmake -f /homes/sjg/make-tests/ternary A=ok
The answer is known
The answer is ok
The answer is ok
$

I've committed this, since it was totally broken.
Will add a test case shortly.

--sjg

--- var.c~	Mon Jan  5 15:09:17 2004
+++ var.c	Thu Jan  8 15:47:51 2004
@@ -2881,6 +2885,9 @@
 		    } else {
 			newStr = UNCONST(pattern.rhs);
 			free(UNCONST(pattern.lhs));
+		    }
+		    if (v->flags & VAR_JUNK) {
+			v->flags |= VAR_KEEP;
 		    }
 		    break;
 		}