diff options
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) #define EXP_RECORD 0x20 /* need to record arguments for ifs breakup */ #define EXP_VARTILDE2 0x40 /* expand tildes after colons only */ #define EXP_WORD 0x80 /* expand word in parameter expansion */ -#define EXP_QWORD 0x100 /* expand word in quoted parameter expansion */ +#define EXP_QUOTED 0x100 /* expand word in double quotes */ /* * rmescape() flags */ @@ -6054,7 +6054,7 @@ argstr(char *p, int flags, struct strlist *var_str_list) }; const char *reject = spclchars; int quotes = flags & QUOTES_ESC; - int breakall = flags & EXP_WORD; + int breakall = (flags & (EXP_WORD | EXP_QUOTED)) == EXP_WORD; int inquotes; size_t length; int startloc; @@ -6072,8 +6072,6 @@ argstr(char *p, int flags, struct strlist *var_str_list) flags &= ~EXP_TILDE; tilde: q = p; - if ((unsigned char)*q == CTLESC && (flags & EXP_QWORD)) - q++; if (*q == '~') p = exptilde(p, q, flags); } @@ -6790,7 +6788,7 @@ evalvar(char *p, int flags, struct strlist *var_str_list) if (varlen < 0) { argstr( p, - flags | (quoted ? EXP_TILDE|EXP_QWORD : EXP_TILDE|EXP_WORD), + flags | EXP_TILDE | EXP_WORD | (quoted ? EXP_QUOTED : 0), var_str_list ); 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 @@ +unset a +echo "${a:-~root}" |