chiark / gitweb /
fileio: also escape $ and ` when writing out env vars
authorMantas Mikulėnas <grawity@gmail.com>
Sun, 14 Apr 2013 11:54:09 +0000 (14:54 +0300)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 17 Apr 2013 04:32:02 +0000 (00:32 -0400)
These are also considered special by sh and bash.

src/shared/fileio.c

index 400a416..617afea 100644 (file)
@@ -529,11 +529,11 @@ static void write_env_var(FILE *f, const char *v) {
         p++;
         fwrite(v, 1, p-v, f);
 
-        if (string_has_cc(p) || chars_intersect(p, WHITESPACE "\'\"\\")) {
+        if (string_has_cc(p) || chars_intersect(p, WHITESPACE "\'\"\\`$")) {
                 fputc('\"', f);
 
                 for (; *p; p++) {
-                        if (strchr("\'\"\\", *p))
+                        if (strchr("\'\"\\`$", *p))
                                 fputc('\\', f);
 
                         fputc(*p, f);