diff options
author | obrien <obrien@FreeBSD.org> | 2012-05-31 00:36:56 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2012-05-31 00:36:56 +0000 |
commit | 0a0b64846677c0b6ca231245db078844282ad05d (patch) | |
tree | b1ba2d47fe68ed98009dc79572005fd2b21ea789 /usr.bin/make/var.c | |
parent | e58f0a7d2ffac924d6141bd8fe6b68ac99118d3a (diff) | |
download | FreeBSD-src-0a0b64846677c0b6ca231245db078844282ad05d.zip FreeBSD-src-0a0b64846677c0b6ca231245db078844282ad05d.tar.gz |
Add "-V '${VAR}'" variable expansion from Portable Berkeley Make.
Submitted by: Simon Gerraty <sjg@juniper.net>
Diffstat (limited to 'usr.bin/make/var.c')
-rw-r--r-- | usr.bin/make/var.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 341ee79..477c4a9 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -2593,7 +2593,7 @@ void Var_Print(Lst *vlist, Boolean expandVars) { LstNode *n; - const char *name; + char *name; LST_FOREACH(n, vlist) { name = Lst_Datum(n); @@ -2601,13 +2601,17 @@ Var_Print(Lst *vlist, Boolean expandVars) char *value; char *v; - v = emalloc(strlen(name) + 1 + 3); - sprintf(v, "${%s}", name); - + if (*name == '$') { + v = name; + } else { + v = emalloc(strlen(name) + 1 + 3); + sprintf(v, "${%s}", name); + } value = Buf_Peel(Var_Subst(v, VAR_GLOBAL, FALSE)); printf("%s\n", value); - free(v); + if (v != name) + free(v); free(value); } else { const char *value = Var_Value(name, VAR_GLOBAL); |