aboutsummaryrefslogtreecommitdiff
path: root/lib/environment.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2020-06-07 01:54:20 -0400
committerGitHub <noreply@github.com>2020-06-07 01:54:20 -0400
commitbd83a3adb8cf3455f6515a6527f2d1293dd08ca1 (patch)
tree17b6aa92a38d92876cf6254c85b4e991005c889c /lib/environment.c
parent9be2ab9a7578eb9f4f0d784267504cde379282ee (diff)
parent36aa0989cda8fe658bc5b1d2079a20100112c41a (diff)
downloadspmc-bd83a3adb8cf3455f6515a6527f2d1293dd08ca1.tar.gz
Merge pull request #45 from jhunkeler/manfests-runtime
Diffstat (limited to 'lib/environment.c')
-rw-r--r--lib/environment.c8
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