[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox-cvs
Subject:    [Bug 14526] New: possible wrong behaviour with patterns double [ with no closing ]
From:       bugzilla () busybox ! net
Date:       2022-01-17 3:28:46
Message-ID: bug-14526-161 () https ! bugs ! busybox ! net/
[Download RAW message or body]

https://bugs.busybox.net/show_bug.cgi?id=14526

            Bug ID: 14526
           Summary: possible wrong behaviour with patterns double [ with
                    no closing ]
           Product: Busybox
           Version: 1.30.x
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Standard Compliance
          Assignee: unassigned@busybox.net
          Reporter: calestyo@scientia.org
                CC: busybox-cvs@busybox.net
  Target Milestone: ---

Hey.


Assuming a pattern of:
[.*^\]
my understanding was that this would actually mean:
- the literal string [. followed by
- the pattern notation special character * (i.e. any string) followed by
- the literal string ^]

Because ] is escaped, it's to be taken literally and in a pattern a [
without corresponding ] is to be taken literally as well.
(see POSIX,
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13
)

That seems to work in busybox sh:
$ case '[.^]' in ([.*^\]) echo match;; (*) echo no match;; esac
match
$ case '[.x^]' in ([.*^\]) echo match;; (*) echo no match;; esac
match
$ case '[.xx^]' in ([.*^\]) echo match;; (*) echo no match;; esac
match


However, adding another [ to the pattern:
[.*^[\]
which should be:
- the literal string [. followed by
- the pattern notation special character * (i.e. any string) followed by
- the literal string ^[]

No longer matches:
$ case '[.^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac
no match
$ case '[.x^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac
no match
$ case '[.xx^[]' in ([.*^[\]) echo match;; (*) echo no match;; esac
no match


Whereas, AFAIU POSIX, it should.

This works, btw. in bash, but neither in dash, nor klibc sh.


Cheers,
Chris.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
busybox-cvs mailing list
busybox-cvs@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic