diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-11-01 18:47:24 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-11-01 18:47:24 +0100 |
| commit | 64981b4c8e88812c322bee3832f1d421ff670ed5 (patch) | |
| tree | d006cbaab733a481ce753a3f900980a78e85badc /shell | |
| parent | a7c065354f820560621aa5f2e90498d6636f41c3 (diff) | |
| download | busybox-w32-64981b4c8e88812c322bee3832f1d421ff670ed5.tar.gz busybox-w32-64981b4c8e88812c322bee3832f1d421ff670ed5.tar.bz2 busybox-w32-64981b4c8e88812c322bee3832f1d421ff670ed5.zip | |
hush: document bugs in [[ =~ ]] comparison
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/hush_test/hush-bugs/strops5_bug.right | 2 | ||||
| -rwxr-xr-x | shell/hush_test/hush-bugs/strops5_bug.tests | 10 | ||||
| -rw-r--r-- | shell/hush_test/hush-test2/strops5.right | 3 | ||||
| -rwxr-xr-x | shell/hush_test/hush-test2/strops5.tests | 13 |
4 files changed, 28 insertions, 0 deletions
diff --git a/shell/hush_test/hush-bugs/strops5_bug.right b/shell/hush_test/hush-bugs/strops5_bug.right new file mode 100644 index 000000000..aba7bb429 --- /dev/null +++ b/shell/hush_test/hush-bugs/strops5_bug.right | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | 4:no:1 | ||
| 2 | 5:YES:0 | ||
diff --git a/shell/hush_test/hush-bugs/strops5_bug.tests b/shell/hush_test/hush-bugs/strops5_bug.tests new file mode 100755 index 000000000..3e24df768 --- /dev/null +++ b/shell/hush_test/hush-bugs/strops5_bug.tests | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | v='*.z' | ||
| 2 | |||
| 3 | # Buggy: | ||
| 4 | # the problem is that expansion rules of LHS and RHS of ~= | ||
| 5 | # should not be the same: in RHS, "$v" and "*" should escape metas | ||
| 6 | # (currently "$v" does not), | ||
| 7 | # but in LHS, they should _not_ do that | ||
| 8 | # (currently "*" does). Thus these cases fail: | ||
| 9 | [[ a.z == "$v" ]]; echo 4:no:$? # BUG: "$v" expands to *.z | ||
| 10 | [[ "*".z == ?.z ]]; echo 5:YES:$? # BUG: "*" expands to \* | ||
diff --git a/shell/hush_test/hush-test2/strops5.right b/shell/hush_test/hush-test2/strops5.right new file mode 100644 index 000000000..9ed4d6569 --- /dev/null +++ b/shell/hush_test/hush-test2/strops5.right | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | 1:YES:0 | ||
| 2 | 2:no:1 | ||
| 3 | 3:YES:0 | ||
diff --git a/shell/hush_test/hush-test2/strops5.tests b/shell/hush_test/hush-test2/strops5.tests new file mode 100755 index 000000000..ee01e5c30 --- /dev/null +++ b/shell/hush_test/hush-test2/strops5.tests | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | v='*.z' | ||
| 2 | [[ a.z = *.z ]]; echo 1:YES:$? | ||
| 3 | [[ a.z = "*".z ]]; echo 2:no:$? | ||
| 4 | [[ a.z == $v ]]; echo 3:YES:$? | ||
| 5 | |||
| 6 | # Buggy: | ||
| 7 | # the problem is that expansion rules of LHS and RHS of ~= | ||
| 8 | # should not be the same: in RHS, "$v" and "*" should escape metas | ||
| 9 | # (currently "$v" does not), | ||
| 10 | # but in LHS, they should _not_ do that | ||
| 11 | # (currently "*" does). Thus these cases fail: | ||
| 12 | #[[ a.z == "$v" ]]; echo 4:no:$? # BUG: "$v" expands to *.z | ||
| 13 | #[[ "*".z == ?.z ]]; echo 5:YES:$? # BUG: "*" expands to \* | ||
