diff options
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/ash_test/ash-vars/var_backslash1.right | 25 | ||||
| -rwxr-xr-x | shell/ash_test/ash-vars/var_backslash1.tests | 37 | ||||
| -rw-r--r-- | shell/hush_test/hush-bugs/var_backslash1.right | 25 | ||||
| -rwxr-xr-x | shell/hush_test/hush-bugs/var_backslash1.tests | 37 |
4 files changed, 124 insertions, 0 deletions
diff --git a/shell/ash_test/ash-vars/var_backslash1.right b/shell/ash_test/ash-vars/var_backslash1.right new file mode 100644 index 000000000..066294838 --- /dev/null +++ b/shell/ash_test/ash-vars/var_backslash1.right | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | a is '\*bc' | ||
| 2 | b is '\' | ||
| 3 | c is '*' | ||
| 4 | ${a##?*} removes everything: || | ||
| 5 | ${a##?"*"} removes \*: |bc| - matches one char, then * | ||
| 6 | ${a##\*} removes nothing: |\*bc| - first char is not * | ||
| 7 | ${a##\\*} removes everything: || - matches \, then all | ||
| 8 | ${a##\\\*} removes \*: || - matches \, then * | ||
| 9 | ${a##?$c} removes everything: || - matches one char, then all | ||
| 10 | ${a##?"$c"} removes \*: |bc| - matches one char, then * | ||
| 11 | ${a##\\$c} removes everything: || - matches \, then all | ||
| 12 | ${a##\\"$c"} removes \*: |bc| - matches \, then * | ||
| 13 | ${a##$b} removes \: |*bc| - matches \ | ||
| 14 | ${a##"$b"} removes \: |*bc| - matches \ | ||
| 15 | |||
| 16 | ${a##"$b"?} removes \*: |bc| - matches \, then one char | ||
| 17 | ${a##"$b"*} removes everything: || - matches \, then all | ||
| 18 | ${a##"$b""?"} removes nothing: |\*bc| - second char is not ? | ||
| 19 | ${a##"$b""*"} removes \*: |bc| - matches \, then * | ||
| 20 | ${a##"$b"\*} removes \*: |bc| - matches \, then * | ||
| 21 | ${a##"$b"$c} removes everything:|| - matches \, then all | ||
| 22 | ${a##"$b""$c"} removes \*: |bc| - matches \, then * | ||
| 23 | ${a##"$b?"} removes nothing: |\*bc| - second char is not ? | ||
| 24 | ${a##"$b*"} removes \*: |bc| - matches \, then * | ||
| 25 | ${a##"$b$c"} removes \*: |bc| - matches \, then * | ||
diff --git a/shell/ash_test/ash-vars/var_backslash1.tests b/shell/ash_test/ash-vars/var_backslash1.tests new file mode 100755 index 000000000..7d865c929 --- /dev/null +++ b/shell/ash_test/ash-vars/var_backslash1.tests | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | a='\*bc' | ||
| 2 | b='\' | ||
| 3 | c='*' | ||
| 4 | echo "a is '$a'" | ||
| 5 | echo "b is '$b'" | ||
| 6 | echo "c is '$c'" | ||
| 7 | echo '${a##?*} removes everything: '"|${a##?*}|" | ||
| 8 | echo '${a##?"*"} removes \*: '"|${a##?"*"}|"' - matches one char, then *' | ||
| 9 | echo '${a##\*} removes nothing: '"|${a##\*}|"' - first char is not *' | ||
| 10 | echo '${a##\\*} removes everything: '"|${a##\\*}|"' - matches \, then all' | ||
| 11 | echo '${a##\\\*} removes \*: '"|${a##\\*}|"' - matches \, then *' | ||
| 12 | echo '${a##?$c} removes everything: '"|${a##?$c}|"' - matches one char, then all' | ||
| 13 | echo '${a##?"$c"} removes \*: '"|${a##?"$c"}|"' - matches one char, then *' | ||
| 14 | echo '${a##\\$c} removes everything: '"|${a##\\$c}|"' - matches \, then all' | ||
| 15 | echo '${a##\\"$c"} removes \*: '"|${a##\\"$c"}|"' - matches \, then *' | ||
| 16 | echo '${a##$b} removes \: '"|${a##$b}|"' - matches \' | ||
| 17 | echo '${a##"$b"} removes \: '"|${a##"$b"}|"' - matches \' | ||
| 18 | echo | ||
| 19 | ## In bash, this isn't working as expected | ||
| 20 | #echo '${a##$b?} removes \*: '"|${a##$b?}|"' - matches \, then one char' # bash prints |\*bc| | ||
| 21 | #echo '${a##$b*} removes everything: '"|${a##$b*}|"' - matches \, then all' # bash prints |\*bc| | ||
| 22 | #echo '${a##$b$c} removes everything: '"|${a##$b$c}|"' - matches \, then all' # bash prints |\*bc| | ||
| 23 | #echo '${a##$b"$c"} removes \*: '"|${a##$b"$c"}|"' - matches \, then *' # bash prints |\*bc| | ||
| 24 | ## the cause seems to be that $b emits backslash that "glues" onto next character if there is one: | ||
| 25 | ## a='\*bc'; b='\'; c='*'; echo "|${a##?$b*}|" # bash prints |bc| - the $b* works as \* (matches literal *) | ||
| 26 | ## a='\*bc'; b='\'; c='*'; echo "|${a##\\$b*}|" # bash prints |bc| | ||
| 27 | #echo | ||
| 28 | echo '${a##"$b"?} removes \*: '"|${a##"$b"?}|"' - matches \, then one char' | ||
| 29 | echo '${a##"$b"*} removes everything: '"|${a##"$b"*}|"' - matches \, then all' | ||
| 30 | echo '${a##"$b""?"} removes nothing: '"|${a##"$b""?"}|"' - second char is not ?' # bash prints |bc| | ||
| 31 | echo '${a##"$b""*"} removes \*: '"|${a##"$b""*"}|"' - matches \, then *' | ||
| 32 | echo '${a##"$b"\*} removes \*: '"|${a##"$b"\*}|"' - matches \, then *' | ||
| 33 | echo '${a##"$b"$c} removes everything:'"|${a##"$b"$c}|"' - matches \, then all' | ||
| 34 | echo '${a##"$b""$c"} removes \*: '"|${a##"$b""$c"}|"' - matches \, then *' | ||
| 35 | echo '${a##"$b?"} removes nothing: '"|${a##"$b?"}|"' - second char is not ?' # bash prints |bc| | ||
| 36 | echo '${a##"$b*"} removes \*: '"|${a##"$b*"}|"' - matches \, then *' # bash prints || | ||
| 37 | echo '${a##"$b$c"} removes \*: '"|${a##"$b$c"}|"' - matches \, then *' | ||
diff --git a/shell/hush_test/hush-bugs/var_backslash1.right b/shell/hush_test/hush-bugs/var_backslash1.right new file mode 100644 index 000000000..066294838 --- /dev/null +++ b/shell/hush_test/hush-bugs/var_backslash1.right | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | a is '\*bc' | ||
| 2 | b is '\' | ||
| 3 | c is '*' | ||
| 4 | ${a##?*} removes everything: || | ||
| 5 | ${a##?"*"} removes \*: |bc| - matches one char, then * | ||
| 6 | ${a##\*} removes nothing: |\*bc| - first char is not * | ||
| 7 | ${a##\\*} removes everything: || - matches \, then all | ||
| 8 | ${a##\\\*} removes \*: || - matches \, then * | ||
| 9 | ${a##?$c} removes everything: || - matches one char, then all | ||
| 10 | ${a##?"$c"} removes \*: |bc| - matches one char, then * | ||
| 11 | ${a##\\$c} removes everything: || - matches \, then all | ||
| 12 | ${a##\\"$c"} removes \*: |bc| - matches \, then * | ||
| 13 | ${a##$b} removes \: |*bc| - matches \ | ||
| 14 | ${a##"$b"} removes \: |*bc| - matches \ | ||
| 15 | |||
| 16 | ${a##"$b"?} removes \*: |bc| - matches \, then one char | ||
| 17 | ${a##"$b"*} removes everything: || - matches \, then all | ||
| 18 | ${a##"$b""?"} removes nothing: |\*bc| - second char is not ? | ||
| 19 | ${a##"$b""*"} removes \*: |bc| - matches \, then * | ||
| 20 | ${a##"$b"\*} removes \*: |bc| - matches \, then * | ||
| 21 | ${a##"$b"$c} removes everything:|| - matches \, then all | ||
| 22 | ${a##"$b""$c"} removes \*: |bc| - matches \, then * | ||
| 23 | ${a##"$b?"} removes nothing: |\*bc| - second char is not ? | ||
| 24 | ${a##"$b*"} removes \*: |bc| - matches \, then * | ||
| 25 | ${a##"$b$c"} removes \*: |bc| - matches \, then * | ||
diff --git a/shell/hush_test/hush-bugs/var_backslash1.tests b/shell/hush_test/hush-bugs/var_backslash1.tests new file mode 100755 index 000000000..7d865c929 --- /dev/null +++ b/shell/hush_test/hush-bugs/var_backslash1.tests | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | a='\*bc' | ||
| 2 | b='\' | ||
| 3 | c='*' | ||
| 4 | echo "a is '$a'" | ||
| 5 | echo "b is '$b'" | ||
| 6 | echo "c is '$c'" | ||
| 7 | echo '${a##?*} removes everything: '"|${a##?*}|" | ||
| 8 | echo '${a##?"*"} removes \*: '"|${a##?"*"}|"' - matches one char, then *' | ||
| 9 | echo '${a##\*} removes nothing: '"|${a##\*}|"' - first char is not *' | ||
| 10 | echo '${a##\\*} removes everything: '"|${a##\\*}|"' - matches \, then all' | ||
| 11 | echo '${a##\\\*} removes \*: '"|${a##\\*}|"' - matches \, then *' | ||
| 12 | echo '${a##?$c} removes everything: '"|${a##?$c}|"' - matches one char, then all' | ||
| 13 | echo '${a##?"$c"} removes \*: '"|${a##?"$c"}|"' - matches one char, then *' | ||
| 14 | echo '${a##\\$c} removes everything: '"|${a##\\$c}|"' - matches \, then all' | ||
| 15 | echo '${a##\\"$c"} removes \*: '"|${a##\\"$c"}|"' - matches \, then *' | ||
| 16 | echo '${a##$b} removes \: '"|${a##$b}|"' - matches \' | ||
| 17 | echo '${a##"$b"} removes \: '"|${a##"$b"}|"' - matches \' | ||
| 18 | echo | ||
| 19 | ## In bash, this isn't working as expected | ||
| 20 | #echo '${a##$b?} removes \*: '"|${a##$b?}|"' - matches \, then one char' # bash prints |\*bc| | ||
| 21 | #echo '${a##$b*} removes everything: '"|${a##$b*}|"' - matches \, then all' # bash prints |\*bc| | ||
| 22 | #echo '${a##$b$c} removes everything: '"|${a##$b$c}|"' - matches \, then all' # bash prints |\*bc| | ||
| 23 | #echo '${a##$b"$c"} removes \*: '"|${a##$b"$c"}|"' - matches \, then *' # bash prints |\*bc| | ||
| 24 | ## the cause seems to be that $b emits backslash that "glues" onto next character if there is one: | ||
| 25 | ## a='\*bc'; b='\'; c='*'; echo "|${a##?$b*}|" # bash prints |bc| - the $b* works as \* (matches literal *) | ||
| 26 | ## a='\*bc'; b='\'; c='*'; echo "|${a##\\$b*}|" # bash prints |bc| | ||
| 27 | #echo | ||
| 28 | echo '${a##"$b"?} removes \*: '"|${a##"$b"?}|"' - matches \, then one char' | ||
| 29 | echo '${a##"$b"*} removes everything: '"|${a##"$b"*}|"' - matches \, then all' | ||
| 30 | echo '${a##"$b""?"} removes nothing: '"|${a##"$b""?"}|"' - second char is not ?' # bash prints |bc| | ||
| 31 | echo '${a##"$b""*"} removes \*: '"|${a##"$b""*"}|"' - matches \, then *' | ||
| 32 | echo '${a##"$b"\*} removes \*: '"|${a##"$b"\*}|"' - matches \, then *' | ||
| 33 | echo '${a##"$b"$c} removes everything:'"|${a##"$b"$c}|"' - matches \, then all' | ||
| 34 | echo '${a##"$b""$c"} removes \*: '"|${a##"$b""$c"}|"' - matches \, then *' | ||
| 35 | echo '${a##"$b?"} removes nothing: '"|${a##"$b?"}|"' - second char is not ?' # bash prints |bc| | ||
| 36 | echo '${a##"$b*"} removes \*: '"|${a##"$b*"}|"' - matches \, then *' # bash prints || | ||
| 37 | echo '${a##"$b$c"} removes \*: '"|${a##"$b$c"}|"' - matches \, then *' | ||
