Re: [BUG] 'case' does not match double-quoted backslash
Op 13-02-18 om 14:44 schreef Denys Vlasenko: > Fixed in git, thanks. As already signaled on the dash list, this introduces a new bug: $ ./ash -c 'foo=a; echo "<${foo#[a\]]}>"' Expected output: <> - M. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [BUG] 'case' does not match double-quoted backslash
Fixed in git, thanks. On Tue, Feb 13, 2018 at 11:42 AM, Martijn Dekker wrote: > Op 13-02-18 om 08:12 schreef dietmar.schind...@manroland-web.com: >> Von: Kang-Che Sung >> Gesendet: Dienstag, 13. Februar 2018 04:52 >>> It says the backslash is special only when followed by the $ ` " \ >>> characters. >>> That is, \$ \` \" \\ and \ are special, but none of these >>> includes the \z you >>> mentioned, so what you described is an undefined behavior. >> >> "The shall retain its special meaning ... only when >> followed ..." means that in other cases it has no special meaning. >> Having no special meaning does not mean undefined behavior, but >> rather normal behavior (as an ordinary character). > > Precisely. If the standard meant that to be undefined behaviour, it > would explicitly say so (as it does in many cases of actual undefined > behaviour). Also, compare the behaviour of *any* other shell. There is a > clear consensus there. > > But, even if the behaviour were undefined, it should not silently change > from one busybox version to the next. It breaks backwards compatibility. > > - M. > ___ > busybox mailing list > busybox@busybox.net > http://lists.busybox.net/mailman/listinfo/busybox ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [BUG] 'case' does not match double-quoted backslash
Op 13-02-18 om 08:12 schreef dietmar.schind...@manroland-web.com: > Von: Kang-Che Sung > Gesendet: Dienstag, 13. Februar 2018 04:52 >> It says the backslash is special only when followed by the $ ` " \ >> characters. >> That is, \$ \` \" \\ and \ are special, but none of these >> includes the \z you >> mentioned, so what you described is an undefined behavior. > > "The shall retain its special meaning ... only when > followed ..." means that in other cases it has no special meaning. > Having no special meaning does not mean undefined behavior, but > rather normal behavior (as an ordinary character). Precisely. If the standard meant that to be undefined behaviour, it would explicitly say so (as it does in many cases of actual undefined behaviour). Also, compare the behaviour of *any* other shell. There is a clear consensus there. But, even if the behaviour were undefined, it should not silently change from one busybox version to the next. It breaks backwards compatibility. - M. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
AW: [BUG] 'case' does not match double-quoted backslash
> Von: Kang-Che Sung > Gesendet: Dienstag, 13. Februar 2018 04:52 > > On Tue, Feb 13, 2018 at 10:34 AM, Martijn Dekker wrote: > > Op 13-02-18 om 03:09 schreef Kang-Che Sung: > >> Just wondering, why using "\z" and not "\\z" ? > >> The former doesn't seem to be a valid syntax. > > > > It is valid, though. See the POSIX specification: > > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03 > > > > ===begin quote=== > > 2.2.3 Double-Quotes > > [...] > > > > \ > > The shall retain its special meaning as an escape > > character (see Escape Character (Backslash)) only when followed by one > > of the following characters when considered special: > > > > $ ` " \ > > ===end quote=== > > > > So, this should simply work. It worked on ash before. It also works on > > every other POSIX shell, and existing scripts rely on it. > > It says the backslash is special only when followed by the $ ` " \ > characters. > That is, \$ \` \" \\ and \ are special, but none of these > includes the \z you > mentioned, so what you described is an undefined behavior. "The shall retain its special meaning ... only when followed ..." means that in other cases it has no special meaning. Having no special meaning does not mean undefined behavior, but rather normal behavior (as an ordinary character). -- Regards, Dietmar Schindler manroland web systems GmbH | Managing Director: Alexander Wassermann Registered Office: Augsburg | Trade Register: AG Augsburg | HRB-No.: 26816 | VAT: DE281389840 Confidentiality note: This eMail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient, you are hereby notified that any use or dissemination of this communication is strictly prohibited. If you have received this eMail in error, then please delete this eMail. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [BUG] 'case' does not match double-quoted backslash
On Tue, Feb 13, 2018 at 10:34 AM, Martijn Dekker wrote: > Op 13-02-18 om 03:09 schreef Kang-Che Sung: >> Just wondering, why using "\z" and not "\\z" ? >> The former doesn't seem to be a valid syntax. > > It is valid, though. See the POSIX specification: > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03 > > ===begin quote=== > 2.2.3 Double-Quotes > [...] > > \ > The shall retain its special meaning as an escape > character (see Escape Character (Backslash)) only when followed by one > of the following characters when considered special: > > $ ` " \ > ===end quote=== > > So, this should simply work. It worked on ash before. It also works on > every other POSIX shell, and existing scripts rely on it. It says the backslash is special only when followed by the $ ` " \ characters. That is, \$ \` \" \\ and \ are special, but none of these includes the \z you mentioned, so what you described is an undefined behavior. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [BUG] 'case' does not match double-quoted backslash
Op 13-02-18 om 03:09 schreef Kang-Che Sung: > Just wondering, why using "\z" and not "\\z" ? > The former doesn't seem to be a valid syntax. It is valid, though. See the POSIX specification: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02_03 ===begin quote=== 2.2.3 Double-Quotes [...] \ The shall retain its special meaning as an escape character (see Escape Character (Backslash)) only when followed by one of the following characters when considered special: $ ` " \ ===end quote=== So, this should simply work. It worked on ash before. It also works on every other POSIX shell, and existing scripts rely on it. - M. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
Re: [BUG] 'case' does not match double-quoted backslash
On Tue, Feb 13, 2018 at 5:36 AM, Martijn Dekker wrote: > The following outputs BUG in ash: > > case "\z" in > "\z" ) echo ok ;; > * ) echo BUG ;; > esac > > Apparently `case` has trouble matching the "\z" pattern due to the > backslash within the double quotes. Quoting it in any other way works. > > Also, backslash-escaping the backslash within the double quotes is a > workaround. But this is not supposed to be necessary unless the > backslash precedes one of the special characters $, `, ", \, or . > > The bug is in 1.28.0 but not 1.27.0. > > According to my testing, this bug appears to have been introduced by > this commit, which fixed another related bug. > > | commit fda9fafe279d9394ad53313320a949c86f646734 > > | Author: Denys Vlasenko > | Date: Wed Jul 5 19:10:21 2017 +0200 > > | > | ash: fix matching of unicode greek letter rho (cf 81) and similar > cases > | > > | Signed-off-by: Denys Vlasenko Just wondering, why using "\z" and not "\\z" ? The former doesn't seem to be a valid syntax. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox
[BUG] 'case' does not match double-quoted backslash
The following outputs BUG in ash: case "\z" in "\z" ) echo ok ;; * ) echo BUG ;; esac Apparently `case` has trouble matching the "\z" pattern due to the backslash within the double quotes. Quoting it in any other way works. Also, backslash-escaping the backslash within the double quotes is a workaround. But this is not supposed to be necessary unless the backslash precedes one of the special characters $, `, ", \, or . The bug is in 1.28.0 but not 1.27.0. According to my testing, this bug appears to have been introduced by this commit, which fixed another related bug. | commit fda9fafe279d9394ad53313320a949c86f646734 | Author: Denys Vlasenko | Date: Wed Jul 5 19:10:21 2017 +0200 | | ash: fix matching of unicode greek letter rho (cf 81) and similar cases | | Signed-off-by: Denys Vlasenko Thanks, - M. ___ busybox mailing list busybox@busybox.net http://lists.busybox.net/mailman/listinfo/busybox