diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-06-07 00:47:06 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2020-06-07 00:47:13 -0400 |
commit | 2cb2e138ce683612db57648987d18418c414e2db (patch) | |
tree | 5576ca0537edc5613032fdd121d20dd67ea811ac /lib/environment.c | |
parent | 9be2ab9a7578eb9f4f0d784267504cde379282ee (diff) | |
download | spmc-2cb2e138ce683612db57648987d18418c414e2db.tar.gz |
Remove invalid escape character
Diffstat (limited to 'lib/environment.c')
-rw-r--r-- | lib/environment.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/environment.c b/lib/environment.c index 3144982..d9419f0 100644 --- a/lib/environment.c +++ b/lib/environment.c @@ -102,13 +102,13 @@ void runtime_export(RuntimeEnv *env, char **keys) { if (keys != NULL) { for (size_t j = 0; keys[j] != NULL; j++) { if (strcmp(keys[j], key) == 0) { - sprintf(output, "%s %s=\"%s\"", export_command, key, value ? value : ""); + sprintf(output, "%s=\"%s\"\n%s %s", key, value ? value : "", export_command, key); puts(output); } } } else { - sprintf(output, "%s %s=\"%s\"", export_command, key, value ? value : ""); + sprintf(output, "%s=\"%s\"\n%s %s", key, value ? value : "", export_command, key); puts(output); } free(value); @@ -249,7 +249,6 @@ char *runtime_get(RuntimeEnv *env, const char *key) { char *runtime_expand_var(RuntimeEnv *env, const char *input) { const char delim = '$'; const char *delim_literal = "$$"; - const char *escape = "\\"; char *expanded = NULL; // If there's no environment variables to process return a copy of the input string @@ -271,9 +270,8 @@ char *runtime_expand_var(RuntimeEnv *env, const char *input) { memset(var, '\0', MAXNAMLEN); // zero out name // Handle literal statement "$$var" - // Value becomes "\$var" + // Value becomes "$var" (unexpanded) if (strncmp(&input[i], delim_literal, strlen(delim_literal)) == 0) { - strncat(expanded, escape, strlen(escape)); strncat(expanded, &delim, 1); i += strlen(delim_literal); // Ignore opening brace |