From e0dbe037b7fc3dd7979df288e04f0c09a71c13e9 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 12 Oct 2007 16:05:14 +0000 Subject: Allow ${foo} syntax for variables. --- tools/gpg-connect-agent.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'tools/gpg-connect-agent.c') 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; -- cgit v1.2.3