From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7892 invoked by alias); 14 May 2015 17:43:58 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35134 Received: (qmail 24297 invoked from network); 14 May 2015 17:43:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f5-f794b6d000001495-d7-5554ded83c78 Date: Thu, 14 May 2015 18:43:32 +0100 From: Peter Stephenson To: Martijn Dekker , zsh-workers@zsh.org Subject: Re: 'case' pattern matching bug with bracket expressions Message-id: <20150514184332.3803584d@pwslap01u.europe.root.pri> In-reply-to: <5554D65B.8070500@inlv.org> References: <55549FB2.80705@inlv.org> <20150514154238.0e547ff0@pwslap01u.europe.root.pri> <5554C3A5.4030205@inlv.org> <20150514171716.69cd99c9@pwslap01u.europe.root.pri> <5554D65B.8070500@inlv.org> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDLMWRmVeSWpSXmKPExsVy+t/xq7o37oWEGlzdI25xqivF4mDzQyYH Jo+/aycxeaw6+IEpgCmKyyYlNSezLLVI3y6BK+N313eWgkecFXdm7WRqYLzJ3sXIySEhYCLx 8tsmRghbTOLCvfVsXYxcHEICSxkl9r6YwQaSEBJoYJK49jAPIrGNUaLl822mLkYODhYBVYnW lcUgNWwChhJTN80GGyQiYCXxaeYfMFtYwFHiV38nK4jNK2AvMeXCWrA4p4CGxJ6/L6CWnWaU +HRiGxNIgl9AX+Lq309MEBfZS8y8coYRollQ4sfkeywgNrOAlsTmbU2sELa8xOY1b5khDlWX uHF3N/sERqFZSFpmIWmZhaRlASPzKkbR1NLkguKk9FwjveLE3OLSvHS95PzcTYyQMP66g3Hp MatDjAIcjEo8vByGwaFCrIllxZW5hxglOJiVRHjFb4SECvGmJFZWpRblxxeV5qQWH2KU5mBR Eueduet9iJBAemJJanZqakFqEUyWiYNTqoFRXmez5MH54lJ9se1X8o64TmPiZ028dbXn9/qz XNf+stxqiLdj5950h7PYNaX14MQdhTdbZaNjX68wnNYXVPphBn+r1u5TkzcJ8/PzyP5KzQhL Pd+ZYF+hd+GYXWopy7LA/Q8nuwbPTuFw8OFfxrhF/duTfyrBOv8P39S9EL34U4dD1XbZU6+U WIozEg21mIuKEwHt0/WUXwIAAA== On Thu, 14 May 2015 18:07:39 +0100 Martijn Dekker wrote: > However, the more insidious case that bit me: > > case abc in ( [] | [!a-z]* ) echo yes ;; ( * ) echo no ;; esac > empty='' > case abc in ( ["$empty"] | [!a-z]* ) echo yes ;; ( * ) echo no ;; esac > > still produces a false positive even with the patch. This is hairy because you're relying on whitespace performing word splitting in a case where you don't need whitespace according to the grammar anyway, i.e. if you have the valid expression case abc in (["$empty"]|[!a-z]*) echo yes ;; (*) echo no ;; esac it can only be parsed the way zsh parses it --- you'll find bash does the same. I'll have a look at changing the way we handle whitespace in bracketed expressions in POSIX mode (POSIX_STRINGS option? That's about the closest I can see and underworked at the moment). The above still needs some work, though, since we don't currently word split case statements. I think that probably is required by the standard since it specifies word (though not word list) handling, i.e. implying the same as command line words but with an additional "|" token between words. That's probably going to have to wait till after 5.0.8. pws