5e6fe9c68ebaccf8b0e9aace80bce35f7e211788 — Drew DeVault 2 months ago 5fd9b00
builtin/export: expand tildes in value

Fixes the following:

export PATH=~/bin:$PATH
1 files changed, 5 insertions(+), 1 deletions(-)

M builtin/export.c
M builtin/export.c => builtin/export.c +5 -1
@@ 4,6 4,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include "builtin.h"
+#include "shell/word.h"
 
 static const char export_usage[] = "usage: %s -p|name[=word]...\n";
 


@@ 52,8 53,11 @@
 			free(key);
 			return 1;
 		}
-		mrsh_env_set(state, key, val, attrib | prev_attribs);
+		char *new_val = strdup(val);
+		expand_tilde(state, &new_val);
+		mrsh_env_set(state, key, new_val, attrib | prev_attribs);
 		free(key);
+		free(new_val);
 	}
 
 	return 0;