From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15656 invoked by alias); 18 Jan 2016 04:23:19 -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: 37667 Received: (qmail 17013 invoked from network); 18 Jan 2016 04:23:15 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Message-ID: <569C68AB.2010806@inlv.org> Date: Mon, 18 Jan 2016 05:23:07 +0100 From: Martijn Dekker User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: zsh-workers@zsh.org, ast-developers@lists.research.att.com Subject: [BUG] quoting within bracket patterns has no effect Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Quotes should disable the special meaning of characters in glob patterns[*]. So this: case b in ( ['a-c'] ) echo 'false match' ;; ( [a-c] ) echo 'correct match' ;; esac should output "correct match". But on zsh and AT&T ksh93 (and only those), it outputs "false match". Meaning, quoting the characters within the bracket pattern does not disable the special meaning of '-' in the bracket pattern. This hinders a realistic use case: the ability to pass a series of arbitrary characters in a variable for use within a bracket pattern. Quoting the variable does not have any effect; if the series contains a '-', the result is unexpected. For example: mychars='abs$ad-f3ra' # arbitrary series of characters containing '-' somevar=qezm # this contains none of the characters above case $somevar in ( *["$mychars"]* ) echo "$somevar contains one of $mychars" ;; esac produces a false positive on zsh and ksh93. A workaround is to make sure the '-', if any, is always last in the string of characters to match against. The same thing also affects glob patterns in other contexts, e.g. removing characters using parameter substitution. Other shells, at least bash, (d)ash variants, pdksh, mksh and yash, all act like POSIX says they should, according to my tests. Thanks, - Martijn [*] "If any character (ordinary, shell special, or pattern special) is quoted, that pattern shall match the character itself." http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_01