~emersion/mrsh-dev

builtin/export: expand tildes in value v1 PROPOSED

Pushed:

To git.sr.ht:~emersion/mrsh
   5fd9b0058eac..5e6fe9c68eba  master -> master

Thanks!
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~emersion/mrsh-dev/%3C20190902014403.19045-1-sir%40cmpwn.com%3E/mbox | git am -3
Learn more about email & git

[PATCH] builtin/export: expand tildes in value Export this patch

Fixes the following:

export PATH=~/bin:$PATH
---
 builtin/export.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/builtin/export.c b/builtin/export.c
index a48ddc1..896f867 100644
--- a/builtin/export.c
@@ -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 @@ int builtin_export(struct mrsh_state *state, int argc, char *argv[]) {
 			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;
-- 
2.23.0
Pushed:

To git.sr.ht:~emersion/mrsh
   5fd9b0058eac..5e6fe9c68eba  master -> master

Thanks!
View this thread in the archives