summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2018-01-09 17:25:58 +0100
committerDenys Vlasenko2018-01-09 17:25:58 +0100
commitd1df1a709f05a737d2477a08eea8c743e83f8f8f (patch)
tree090d99fabe279d87b491f4b4634a2b7e0e3c09c2 /shell
parent740058b42bbfdab225706f8284e8d72b74a5df3b (diff)
downloadbusybox-d1df1a709f05a737d2477a08eea8c743e83f8f8f.zip
busybox-d1df1a709f05a737d2477a08eea8c743e83f8f8f.tar.gz
ash: add comment explaining last change
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 5381f34..83a8e77 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -6756,6 +6756,10 @@ subevalvar(char *p, char *varname, int strloc, int subtype,
// p, varname, strloc, subtype, startloc, varflags, quotes);
#if BASH_PATTERN_SUBST
+ /* For "${v/pattern/repl}", we must find the delimiter _before_
+ * argstr() call expands possible variable references in pattern:
+ * think about "v=a; a=a/; echo ${v/$a/r}" case.
+ */
repl = NULL;
if (subtype == VSREPLACE || subtype == VSREPLACEALL) {
/* Find '/' and replace with NUL */
@@ -6770,11 +6774,8 @@ subevalvar(char *p, char *varname, int strloc, int subtype,
*repl = '\0';
break;
}
- if ((unsigned char)*repl == CTLESC
- && repl[1]
- ) {
+ if ((unsigned char)*repl == CTLESC && repl[1])
repl++;
- }
repl++;
}
}
@@ -6941,11 +6942,10 @@ subevalvar(char *p, char *varname, int strloc, int subtype,
if (!repl) {
//bb_error_msg("str9:'%s' slash_pos:%d", str, slash_pos);
+ repl = nullstr;
if (slash_pos >= 0) {
repl = str + slash_pos;
*repl++ = '\0';
- } else {
- repl = nullstr;
}
}
//bb_error_msg("str:'%s' repl:'%s'", str, repl);