diff options
author | jkh <jkh@FreeBSD.org> | 1997-01-16 10:24:09 +0000 |
---|---|---|
committer | jkh <jkh@FreeBSD.org> | 1997-01-16 10:24:09 +0000 |
commit | b5a526ab91ac8dc6d5b040394aa64dfa85a3a940 (patch) | |
tree | a8aea9644ebcfb3ee879869a388959c83e0bee35 /release/sysinstall/variable.c | |
parent | 4a4bd14c4c5a8bd3eadd89f2fefc58ca8315b44d (diff) | |
download | FreeBSD-src-b5a526ab91ac8dc6d5b040394aa64dfa85a3a940.zip FreeBSD-src-b5a526ab91ac8dc6d5b040394aa64dfa85a3a940.tar.gz |
Clean up a long-standing bug in the scripting code. You could set variables,
but you couldn't call functions! Now you can do both.
Guard against whitespace pollution in variable names.
Diffstat (limited to 'release/sysinstall/variable.c')
-rw-r--r-- | release/sysinstall/variable.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/release/sysinstall/variable.c b/release/sysinstall/variable.c index 8ca79fc..824b0cb 100644 --- a/release/sysinstall/variable.c +++ b/release/sysinstall/variable.c @@ -42,6 +42,13 @@ static void make_variable(char *var, char *value) { Variable *vp; + char *cp; + + /* Trim leading and trailing whitespace */ + var = string_skipwhite(string_prune(var)); + + if (!var || !*var) + return; /* Put it in the environment in any case */ setenv(var, value, 1); @@ -80,7 +87,7 @@ variable_set(char *var) if ((cp = index(tmp, '=')) == NULL) msgFatal("Invalid variable format: %s", var); *(cp++) = '\0'; - make_variable(tmp, cp); + make_variable(tmp, string_skipwhite(cp)); } void @@ -108,7 +115,7 @@ variable_unset(char *var) unsetenv(var); if ((cp = index(var, '=')) != NULL) { sstrncpy(name, cp, cp - var); - var = name; + var = string_skipwhite(string_prune(name)); } /* Now search to see if it's in our list, if we have one.. */ |