From 95d82b1fd953a01bc8dadd0c277b79de17b64797 Mon Sep 17 00:00:00 2001 From: Christian Neukirchen Date: Wed, 10 Feb 2016 19:02:45 +0100 Subject: allow environment variables in place of string literals avoids quoting... numeric values are safe to expand inline already. --- lr.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lr.c') diff --git a/lr.c b/lr.c index a90b786..de451fa 100644 --- a/lr.c +++ b/lr.c @@ -396,6 +396,23 @@ parse_string(char **s) ws(); *s = buf ? buf : (char *) ""; return 1; + } else if (*pos == '$') { + char t; + char *e = ++pos; + + while (isalnum((unsigned char) *pos) || *pos == '_') + pos++; + if (e == pos) + parse_error("invalid environment variable name"); + + t = *pos; + *pos = 0; + *s = getenv(e); + if (!*s) + *s = (char *) ""; + *pos = t; + ws(); + return 1; } return 0; -- cgit 1.4.1