summaryrefslogtreecommitdiffstats
path: root/tools/gpg-connect-agent.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2007-10-12 18:05:14 +0200
committerWerner Koch <wk@gnupg.org>2007-10-12 18:05:14 +0200
commite0dbe037b7fc3dd7979df288e04f0c09a71c13e9 (patch)
treeecaf157a5ae1d1b87d4c4e6136d25f7c6cc0839b /tools/gpg-connect-agent.c
parentAdd more sytem variables: cwd, foodir and serverpid. (diff)
downloadgnupg2-e0dbe037b7fc3dd7979df288e04f0c09a71c13e9.tar.xz
gnupg2-e0dbe037b7fc3dd7979df288e04f0c09a71c13e9.zip
Allow ${foo} syntax for variables.
Diffstat (limited to '')
-rw-r--r--tools/gpg-connect-agent.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c
index 6b4cc54ff..cb3f0639d 100644
--- a/tools/gpg-connect-agent.c
+++ b/tools/gpg-connect-agent.c
@@ -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;
}
- for (pend=p+1; *pend && !spacep (pend) && *pend != '$' ; pend++)
- ;
- if (*pend)
+ 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 (p[1] == '{' && *pend == '}')
+ {
+ *pend++ = 0;
+ value = get_var (p+2);
+ }
+ else if (*pend)
{
int save = *pend;
*pend = 0;