From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11819 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: fnmatch bug? escaping of '-' and ']' inside [...] does not work. Date: Tue, 15 Aug 2017 16:25:50 +0200 Message-ID: <20170815142550.GM15263@port70.net> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1502807165 2648 195.159.176.226 (15 Aug 2017 14:26:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 15 Aug 2017 14:26:05 +0000 (UTC) User-Agent: Mutt/1.6.0 (2016-04-01) Cc: Rich Felker , musl To: Denys Vlasenko Original-X-From: musl-return-11832-gllmg-musl=m.gmane.org@lists.openwall.com Tue Aug 15 16:26:00 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dhcn9-0000M0-Lv for gllmg-musl@m.gmane.org; Tue, 15 Aug 2017 16:25:59 +0200 Original-Received: (qmail 14277 invoked by uid 550); 15 Aug 2017 14:26:03 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14247 invoked from network); 15 Aug 2017 14:26:02 -0000 Mail-Followup-To: Denys Vlasenko , Rich Felker , musl Content-Disposition: inline In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:11819 Archived-At: * Denys Vlasenko [2017-08-15 15:12:17 +0200]: > Moving bbox build to musl did uncover one definite bug. > bbox has gazillion tests for its shells, and one of them > started failing. I added debug printout and with it, > the following fnmatch calls give different results now: > > ash: fnmatch(pattern:'[a\-c]',str:'-',0):1 > ash: fnmatch(pattern:'[\]]',str:']',0):1 > ash: fnmatch(pattern:'[a\]]',str:']',0):1 > > glibc and uclibc threat the above as a match. > > The assumption may be that one should place ']' or '-' > as a first character in the [...] and thus escaping > is not necessary, but shell does not have the luxury > of choosing the pattern, in comes from the script. > it's not clear to me if \ is valid as escape in fnmatch pattern: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_01 in re bracket expression \ is not an escape char, but in the shell i think the pattern should be unquoted first, which may or may not apply to fnmatch bracket expression, depending on how you read the text. i guess if other implementations do the unquoting musl should follow that, but the standard could be improved.