aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c8
-rw-r--r--shell/ash_test/ash-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.right1
-rwxr-xr-xshell/ash_test/ash-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.tests2
3 files changed, 6 insertions, 5 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 4c43f1f30..d87166c4f 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5529,7 +5529,7 @@ ash_arith(const char *s)
5529#define EXP_RECORD 0x20 /* need to record arguments for ifs breakup */ 5529#define EXP_RECORD 0x20 /* need to record arguments for ifs breakup */
5530#define EXP_VARTILDE2 0x40 /* expand tildes after colons only */ 5530#define EXP_VARTILDE2 0x40 /* expand tildes after colons only */
5531#define EXP_WORD 0x80 /* expand word in parameter expansion */ 5531#define EXP_WORD 0x80 /* expand word in parameter expansion */
5532#define EXP_QWORD 0x100 /* expand word in quoted parameter expansion */ 5532#define EXP_QUOTED 0x100 /* expand word in double quotes */
5533/* 5533/*
5534 * rmescape() flags 5534 * rmescape() flags
5535 */ 5535 */
@@ -6054,7 +6054,7 @@ argstr(char *p, int flags, struct strlist *var_str_list)
6054 }; 6054 };
6055 const char *reject = spclchars; 6055 const char *reject = spclchars;
6056 int quotes = flags & QUOTES_ESC; 6056 int quotes = flags & QUOTES_ESC;
6057 int breakall = flags & EXP_WORD; 6057 int breakall = (flags & (EXP_WORD | EXP_QUOTED)) == EXP_WORD;
6058 int inquotes; 6058 int inquotes;
6059 size_t length; 6059 size_t length;
6060 int startloc; 6060 int startloc;
@@ -6072,8 +6072,6 @@ argstr(char *p, int flags, struct strlist *var_str_list)
6072 flags &= ~EXP_TILDE; 6072 flags &= ~EXP_TILDE;
6073 tilde: 6073 tilde:
6074 q = p; 6074 q = p;
6075 if ((unsigned char)*q == CTLESC && (flags & EXP_QWORD))
6076 q++;
6077 if (*q == '~') 6075 if (*q == '~')
6078 p = exptilde(p, q, flags); 6076 p = exptilde(p, q, flags);
6079 } 6077 }
@@ -6790,7 +6788,7 @@ evalvar(char *p, int flags, struct strlist *var_str_list)
6790 if (varlen < 0) { 6788 if (varlen < 0) {
6791 argstr( 6789 argstr(
6792 p, 6790 p,
6793 flags | (quoted ? EXP_TILDE|EXP_QWORD : EXP_TILDE|EXP_WORD), 6791 flags | EXP_TILDE | EXP_WORD | (quoted ? EXP_QUOTED : 0),
6794 var_str_list 6792 var_str_list
6795 ); 6793 );
6796 goto end; 6794 goto end;
diff --git a/shell/ash_test/ash-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.right b/shell/ash_test/ash-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.right
new file mode 100644
index 000000000..4b9b4f038
--- /dev/null
+++ b/shell/ash_test/ash-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.right
@@ -0,0 +1 @@
~root
diff --git a/shell/ash_test/ash-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.tests b/shell/ash_test/ash-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.tests
new file mode 100755
index 000000000..d8eb8fc1b
--- /dev/null
+++ b/shell/ash_test/ash-vars/var-do-not-expand-tilde-in-parameter-expansion-in-quotes.tests
@@ -0,0 +1,2 @@
1unset a
2echo "${a:-~root}"