Op 05-07-17 om 19:15 schreef Denys Vlasenko: > Fix is in git, please try and let me know how does it work.
It fixes the bug I reported, but it introduces a new bug: the presence of a quoted closing square bracket in a pattern (whether it's quoted literally or passed from a variable) causes the pattern to never match. The following all fail: case e in ( *[!ab\]cd]* ) echo ok_sq1 ;; ( * ) echo WRONG_sq1 ;; esac case \] in ( *[ab\]cd]* ) echo ok_sq2 ;; ( * ) echo WRONG_sq2 ;; esac case a in ( *[ab\]cd]* ) echo ok_sq3 ;; ( * ) echo WRONG_sq3 ;; esac Unlike the unicode rho bug, this new bug does not appear to be dependent on the setting of CONFIG_LOCALE_SUPPORT. A quick look at the code shows that you foresaw a potential issue, as all I needed to do to fix the problem was uncomment the line you had already prepared. :) The attached patch uncomments that line and adds the above regression tests to the test suite. ('make check' does not seem to work with my ash-only .config, so I only tested the test scripts manually.) - M.
diff --git a/shell/ash.c b/shell/ash.c index 9b1f579..6be9bae 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -5943,7 +5943,7 @@ rmescapes(char *str, int flag) if (*p == '*' || *p == '?' || *p == '[' - /* || *p == ']' maybe also this? */ + || *p == ']' || *p == '\\' ) { *q++ = '\\'; diff --git a/shell/ash_test/ash-misc/case2.right b/shell/ash_test/ash-misc/case2.right new file mode 100644 index 0000000..726fd9a --- /dev/null +++ b/shell/ash_test/ash-misc/case2.right @@ -0,0 +1,3 @@ +ok_sq1 +ok_sq2 +ok_sq3 diff --git a/shell/ash_test/ash-misc/case2.tests b/shell/ash_test/ash-misc/case2.tests new file mode 100755 index 0000000..3b9b566 --- /dev/null +++ b/shell/ash_test/ash-misc/case2.tests @@ -0,0 +1,16 @@ +#! Quoted closing square brackets in glob patterns. + +case e in +( *[!ab\]cd]* ) echo ok_sq1 ;; +( * ) echo WRONG_sq1 ;; +esac + +case \] in +( *[ab\]cd]* ) echo ok_sq2 ;; +( * ) echo WRONG_sq2 ;; +esac + +case a in +( *[ab\]cd]* ) echo ok_sq3 ;; +( * ) echo WRONG_sq3 ;; +esac
_______________________________________________ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox