aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash.c10
-rw-r--r--shell/ash_test/ash-glob/glob_bkslash_in_var.right4
-rwxr-xr-xshell/ash_test/ash-glob/glob_bkslash_in_var.tests10
-rw-r--r--shell/hush_test/hush-glob/glob_bkslash_in_var.right4
-rwxr-xr-xshell/hush_test/hush-glob/glob_bkslash_in_var.tests10
5 files changed, 32 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c
index ad50537a1..dc1a55a6b 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6236,9 +6236,7 @@ memtodest(const char *p, size_t len, int syntax, int quotes)
6236 if (quotes & QUOTES_ESC) { 6236 if (quotes & QUOTES_ESC) {
6237 int n = SIT(c, syntax); 6237 int n = SIT(c, syntax);
6238 if (n == CCTL 6238 if (n == CCTL
6239 || (((quotes & EXP_FULL) || syntax != BASESYNTAX) 6239 || (syntax != BASESYNTAX && n == CBACK)
6240 && n == CBACK
6241 )
6242 ) { 6240 ) {
6243 USTPUTC(CTLESC, q); 6241 USTPUTC(CTLESC, q);
6244 } 6242 }
@@ -7639,7 +7637,7 @@ expmeta(exp_t *exp, char *name, unsigned name_len, unsigned expdir_len)
7639 } 7637 }
7640 } 7638 }
7641 } else { 7639 } else {
7642 if (*p == '\\') 7640 if (*p == '\\' && p[1])
7643 esc++; 7641 esc++;
7644 if (p[esc] == '/') { 7642 if (p[esc] == '/') {
7645 if (metaflag) 7643 if (metaflag)
@@ -7653,7 +7651,7 @@ expmeta(exp_t *exp, char *name, unsigned name_len, unsigned expdir_len)
7653 return; 7651 return;
7654 p = name; 7652 p = name;
7655 do { 7653 do {
7656 if (*p == '\\') 7654 if (*p == '\\' && p[1])
7657 p++; 7655 p++;
7658 *enddir++ = *p; 7656 *enddir++ = *p;
7659 } while (*p++); 7657 } while (*p++);
@@ -7665,7 +7663,7 @@ expmeta(exp_t *exp, char *name, unsigned name_len, unsigned expdir_len)
7665 if (name < start) { 7663 if (name < start) {
7666 p = name; 7664 p = name;
7667 do { 7665 do {
7668 if (*p == '\\') 7666 if (*p == '\\' && p[1])
7669 p++; 7667 p++;
7670 *enddir++ = *p++; 7668 *enddir++ = *p++;
7671 } while (p < start); 7669 } while (p < start);
diff --git a/shell/ash_test/ash-glob/glob_bkslash_in_var.right b/shell/ash_test/ash-glob/glob_bkslash_in_var.right
new file mode 100644
index 000000000..f1484b9e4
--- /dev/null
+++ b/shell/ash_test/ash-glob/glob_bkslash_in_var.right
@@ -0,0 +1,4 @@
1Unquoted non-matching glob in var:'test*.TMP/\name_doesnt_exist'
2Unquoted matching glob in var: 'testdir.TMP/name'
3Quoted non-matching glob in var: 'test*.TMP/\name_doesnt_exist'
4Quoted matching glob in var: 'test*.TMP/\name'
diff --git a/shell/ash_test/ash-glob/glob_bkslash_in_var.tests b/shell/ash_test/ash-glob/glob_bkslash_in_var.tests
new file mode 100755
index 000000000..e3dedc4ac
--- /dev/null
+++ b/shell/ash_test/ash-glob/glob_bkslash_in_var.tests
@@ -0,0 +1,10 @@
1mkdir testdir.TMP
2>testdir.TMP/name
3a="test*.TMP/\name_doesnt_exist"
4b="test*.TMP/\name"
5printf "Unquoted non-matching glob in var:'%s'\n" $a
6printf "Unquoted matching glob in var: '%s'\n" $b
7printf "Quoted non-matching glob in var: '%s'\n" "$a"
8printf "Quoted matching glob in var: '%s'\n" "$b"
9rm -f testdir.TMP/name
10rmdir testdir.TMP
diff --git a/shell/hush_test/hush-glob/glob_bkslash_in_var.right b/shell/hush_test/hush-glob/glob_bkslash_in_var.right
new file mode 100644
index 000000000..f1484b9e4
--- /dev/null
+++ b/shell/hush_test/hush-glob/glob_bkslash_in_var.right
@@ -0,0 +1,4 @@
1Unquoted non-matching glob in var:'test*.TMP/\name_doesnt_exist'
2Unquoted matching glob in var: 'testdir.TMP/name'
3Quoted non-matching glob in var: 'test*.TMP/\name_doesnt_exist'
4Quoted matching glob in var: 'test*.TMP/\name'
diff --git a/shell/hush_test/hush-glob/glob_bkslash_in_var.tests b/shell/hush_test/hush-glob/glob_bkslash_in_var.tests
new file mode 100755
index 000000000..e3dedc4ac
--- /dev/null
+++ b/shell/hush_test/hush-glob/glob_bkslash_in_var.tests
@@ -0,0 +1,10 @@
1mkdir testdir.TMP
2>testdir.TMP/name
3a="test*.TMP/\name_doesnt_exist"
4b="test*.TMP/\name"
5printf "Unquoted non-matching glob in var:'%s'\n" $a
6printf "Unquoted matching glob in var: '%s'\n" $b
7printf "Quoted non-matching glob in var: '%s'\n" "$a"
8printf "Quoted matching glob in var: '%s'\n" "$b"
9rm -f testdir.TMP/name
10rmdir testdir.TMP