ash: fix handling of single-quoted strings in pattern substitution
function old new delta subevalvar 1576 1588 +12 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
f873c63085
commit
c5a1be25ba
5 changed files with 29 additions and 0 deletions
|
@ -7073,6 +7073,11 @@ subevalvar(char *start, char *str, int strloc,
|
||||||
repl = NULL;
|
repl = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/* Skip over quoted 'str'. Example: ${var/'/'} - second / is not a separator */
|
||||||
|
if ((unsigned char)*repl == CTLQUOTEMARK) {
|
||||||
|
while ((unsigned char)*++repl != CTLQUOTEMARK)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (*repl == '/') {
|
if (*repl == '/') {
|
||||||
*repl = '\0';
|
*repl = '\0';
|
||||||
break;
|
break;
|
||||||
|
|
4
shell/ash_test/ash-quoting/dollar_repl_bash2.right
Normal file
4
shell/ash_test/ash-quoting/dollar_repl_bash2.right
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
axxb
|
||||||
|
axxb
|
||||||
|
axxb
|
||||||
|
axxb
|
8
shell/ash_test/ash-quoting/dollar_repl_bash2.tests
Executable file
8
shell/ash_test/ash-quoting/dollar_repl_bash2.tests
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
v="x/x"
|
||||||
|
# The second / is quoted, should not be treated as separator
|
||||||
|
echo a${v/'/'}b
|
||||||
|
# The second / is escaped, should not be treated as separator
|
||||||
|
echo a${v/\/}b
|
||||||
|
|
||||||
|
echo "a${v/'/'}b"
|
||||||
|
echo "a${v/\/}b"
|
4
shell/hush_test/hush-quoting/dollar_repl_bash2.right
Normal file
4
shell/hush_test/hush-quoting/dollar_repl_bash2.right
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
axxb
|
||||||
|
axxb
|
||||||
|
axxb
|
||||||
|
axxb
|
8
shell/hush_test/hush-quoting/dollar_repl_bash2.tests
Executable file
8
shell/hush_test/hush-quoting/dollar_repl_bash2.tests
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
v="x/x"
|
||||||
|
# The second / is quoted, should not be treated as separator
|
||||||
|
echo a${v/'/'}b
|
||||||
|
# The second / is escaped, should not be treated as separator
|
||||||
|
echo a${v/\/}b
|
||||||
|
|
||||||
|
echo "a${v/'/'}b"
|
||||||
|
echo "a${v/\/}b"
|
Loading…
Add table
Add a link
Reference in a new issue