Add "-V '${VAR}'" variable expansion from Portable Berkeley Make.
Submitted by: Simon Gerraty <sjg@juniper.net>
This commit is contained in:
parent
65403eb28f
commit
b3dc6c07e2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=236346
@ -320,6 +320,11 @@ Do not build any targets.
|
|||||||
Multiple instances of this option may be specified;
|
Multiple instances of this option may be specified;
|
||||||
the variables will be printed one per line,
|
the variables will be printed one per line,
|
||||||
with a blank line for each null or undefined variable.
|
with a blank line for each null or undefined variable.
|
||||||
|
If
|
||||||
|
.Ar variable
|
||||||
|
contains a
|
||||||
|
.Sq Ic $
|
||||||
|
then the value will be expanded before printing.
|
||||||
.It Fl v
|
.It Fl v
|
||||||
Be extra verbose.
|
Be extra verbose.
|
||||||
Print any extra information.
|
Print any extra information.
|
||||||
|
@ -2593,7 +2593,7 @@ void
|
|||||||
Var_Print(Lst *vlist, Boolean expandVars)
|
Var_Print(Lst *vlist, Boolean expandVars)
|
||||||
{
|
{
|
||||||
LstNode *n;
|
LstNode *n;
|
||||||
const char *name;
|
char *name;
|
||||||
|
|
||||||
LST_FOREACH(n, vlist) {
|
LST_FOREACH(n, vlist) {
|
||||||
name = Lst_Datum(n);
|
name = Lst_Datum(n);
|
||||||
@ -2601,13 +2601,17 @@ Var_Print(Lst *vlist, Boolean expandVars)
|
|||||||
char *value;
|
char *value;
|
||||||
char *v;
|
char *v;
|
||||||
|
|
||||||
v = emalloc(strlen(name) + 1 + 3);
|
if (*name == '$') {
|
||||||
sprintf(v, "${%s}", name);
|
v = name;
|
||||||
|
} else {
|
||||||
|
v = emalloc(strlen(name) + 1 + 3);
|
||||||
|
sprintf(v, "${%s}", name);
|
||||||
|
}
|
||||||
value = Buf_Peel(Var_Subst(v, VAR_GLOBAL, FALSE));
|
value = Buf_Peel(Var_Subst(v, VAR_GLOBAL, FALSE));
|
||||||
printf("%s\n", value);
|
printf("%s\n", value);
|
||||||
|
|
||||||
free(v);
|
if (v != name)
|
||||||
|
free(v);
|
||||||
free(value);
|
free(value);
|
||||||
} else {
|
} else {
|
||||||
const char *value = Var_Value(name, VAR_GLOBAL);
|
const char *value = Var_Value(name, VAR_GLOBAL);
|
||||||
|
Loading…
Reference in New Issue
Block a user