aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 7b85981ec..e8ec0b1a6 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7185,14 +7185,19 @@ subevalvar(char *start, char *str, int strloc,
7185 if ((unsigned)len > (orig_len - pos)) 7185 if ((unsigned)len > (orig_len - pos))
7186 len = orig_len - pos; 7186 len = orig_len - pos;
7187 7187
7188 for (vstr = startp; pos; vstr++, pos--) { 7188 if (!quotes) {
7189 if (quotes && (unsigned char)*vstr == CTLESC) 7189 loc = mempcpy(startp, startp + pos, len);
7190 } else {
7191 for (vstr = startp; pos != 0; pos--) {
7192 if ((unsigned char)*vstr == CTLESC)
7193 vstr++;
7190 vstr++; 7194 vstr++;
7191 } 7195 }
7192 for (loc = startp; len; len--) { 7196 for (loc = startp; len != 0; len--) {
7193 if (quotes && (unsigned char)*vstr == CTLESC) 7197 if ((unsigned char)*vstr == CTLESC)
7198 *loc++ = *vstr++;
7194 *loc++ = *vstr++; 7199 *loc++ = *vstr++;
7195 *loc++ = *vstr++; 7200 }
7196 } 7201 }
7197 *loc = '\0'; 7202 *loc = '\0';
7198 goto out; 7203 goto out;