From owner-freebsd-current@freebsd.org Fri Apr 7 05:29:08 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E6F36D32037 for ; Fri, 7 Apr 2017 05:29:08 +0000 (UTC) (envelope-from wollman@hergotha.csail.mit.edu) Received: from hergotha.csail.mit.edu (wollman-1-pt.tunnel.tserv4.nyc4.ipv6.he.net [IPv6:2001:470:1f06:ccb::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 87912CA7 for ; Fri, 7 Apr 2017 05:29:08 +0000 (UTC) (envelope-from wollman@hergotha.csail.mit.edu) Received: from hergotha.csail.mit.edu (localhost [127.0.0.1]) by hergotha.csail.mit.edu (8.15.2/8.15.2) with ESMTP id v375T6ud031767; Fri, 7 Apr 2017 01:29:06 -0400 (EDT) (envelope-from wollman@hergotha.csail.mit.edu) Received: (from wollman@localhost) by hergotha.csail.mit.edu (8.15.2/8.14.4/Submit) id v375T5ux031766; Fri, 7 Apr 2017 01:29:05 -0400 (EDT) (envelope-from wollman) Date: Fri, 7 Apr 2017 01:29:05 -0400 (EDT) From: Garrett Wollman Message-Id: <201704070529.v375T5ux031766@hergotha.csail.mit.edu> To: rizzo@i805.com.br Subject: Re: problem with ls, not show a correct list X-Newsgroups: mit.lcs.mail.freebsd-current In-Reply-To: References: <3a8b8ade882d1486aa41b448a9c83b6c@i805.com.br> Organization: none Cc: freebsd-current@freebsd.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (hergotha.csail.mit.edu [127.0.0.1]); Fri, 07 Apr 2017 01:29:06 -0400 (EDT) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on hergotha.csail.mit.edu X-Mailman-Approved-At: Fri, 07 Apr 2017 11:45:12 +0000 X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Apr 2017 05:29:09 -0000 In article <3a8b8ade882d1486aa41b448a9c83b6c@i805.com.br> you write: > > > It's a terrible!!!! Is it a locale bug? Look! > >% locale >LANG=pt_BR.UTF-8 >% touch E >% ls -l [a-z]* >-rw-r--r-- 1 rizzo wheel 0 7 abr 02:06 E No, it's the specification of how character ranges in glob(3) and fnmatch(3) work. In effect, character ranges like [a-z] must be treated as ranges of *collating elements*, not byte ranges, and in your locale, and are considered to be the same collating element, so [a-z] matches both upper- and lower-case Latin letters. This is documented, very obliquely, in sh(1), which also tells you the workaround: a character class. A character class matches any of the characters between the square brackets. A locale-dependent range of characters may be specified using a minus sign. A named class of characters (see wctype(3)) may be specified by surrounding the name with `[:' and `:]'. For example, `[[:alpha:]]' is a shell pattern that matches a single let- ter. So, to match only lower-case letters regardless of your current locale setting, you must use the correct character class: $ locale LANG=pt_BR.UTF-8 LC_CTYPE="pt_BR.UTF-8" LC_COLLATE="pt_BR.UTF-8" LC_TIME="pt_BR.UTF-8" LC_NUMERIC="pt_BR.UTF-8" LC_MONETARY="pt_BR.UTF-8" LC_MESSAGES="pt_BR.UTF-8" LC_ALL= $ ls D E F a b c $ ls [[:lower:]]* a b c The same applies to character class ranges in regular expressions, not just glob(3) patterns. -GAWollman