1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Allow ${foo} syntax for variables.

This commit is contained in:
Werner Koch 2007-10-12 16:05:14 +00:00
parent f8e3f699a9
commit e0dbe037b7
2 changed files with 24 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2007-10-12 Werner Koch <wk@g10code.com>
* gpg-connect-agent.c (substitute_line): Allow ${foo} syntax.
2007-10-11 Werner Koch <wk@g10code.com>
* gpg-connect-agent.c (get_var): Expand environment variables.

View File

@ -228,6 +228,8 @@ get_var (const char *name)
variable_t var;
const char *s;
if (!*name)
return "";
for (var = variable_table; var; var = var->next)
if (!strcmp (var->name, name))
break;
@ -264,9 +266,24 @@ substitute_line (char *buffer)
line = p + 1;
continue;
}
if (p[1] == '{')
{
for (pend=p+2; *pend && *pend != '}' ; pend++)
;
if (!*pend)
return result; /* Unclosed - don't substitute. */
}
else
{
for (pend=p+1; *pend && !spacep (pend) && *pend != '$' ; pend++)
;
if (*pend)
}
if (p[1] == '{' && *pend == '}')
{
*pend++ = 0;
value = get_var (p+2);
}
else if (*pend)
{
int save = *pend;
*pend = 0;