From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY,WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15631 invoked from network); 8 Aug 2021 15:07:45 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Aug 2021 15:07:45 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1628435265; b=GFFTuvRGSUvep1E4OCdKTeJt9HiwmHVoaPYRgUBE4+8Vh9TalDyLX+Ot8M4q+HmWyI93QnjLKJ r46RnTLaEQtbdqE1U61CaaiojgLkJiNM4IZ5yDwnIT66aX0yMNLn9NsGRiurovhnJL0tTRORAr 7DfMG57KS5LSFeM+qMf/o7lQURbdpIUx4n7kLQUl5pvD1whtrfeHWZ8r3eth+8KjGiPx3YH8ds Z9tTQd+DGYq61DIJ1nXi5ySpx/PiXlUlM1F6fS5AZvSEem+7d+lE4WAhkyRsYLoj54/G9cVVRe ttQEZ6g/1BGgtj4QVO0G6NnhV5HCmCxD19GgHtzv3Il3/A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1628435265; bh=oEz7wM96Y7tS5GXlMRloQVGOOfoHNB+cNsYwcSKypBw=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature; b=MWsM1ygjHyvUKCp7N2GcUGRkfA+RUD/myTKMFfROb3IEiw2l/xvQ/lZLQ4g/EhEOtB5UuKk0wY BU71pJZUY4OwsuihahGMlXy3KgG7OrF1LNfGPoREXXRFRyaPf3F0tNjEkA6nvN8Sn+rPTw7EO6 zzBwIVGXimOxoIS24/UoA6l0fHcXNMr1jtRpsR4DM3nLvZE9d7UAwQBcEoo1RDaC2XHELzJ6Nn IzhsnP7goikEOE/vJWTcUabxqNHHcDkDTUFfCXr72GETKxlw2kID9oBmlI69PiOCuS0QocsPMy HjKXNM3blvk3yEAZGZkoGts7VOXyqqQXRCAkAMDrdZEiVQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=oEz7wM96Y7tS5GXlMRloQVGOOfoHNB+cNsYwcSKypBw=; b=f2jH9sRtnGUhwS1MmV98s5Vdwa nGKQhk/QiuukrbyYEdnYvzuK37pja8SHwHRfTw4bpjt8YUO63gg6uhVuIdbyqtNDdxMZn4EtQTq0v UIP4xkxmWU1Tupntp3sxDtcJg5HDzvXgY9zexw/qstOC8903d7Dlc9nnRL/lgU7hxeBnQh8j1Axmg dzjQMWHXrJtfx3wN8KPbj37Eia6VljGT9OQWcBg1svao0N/O9UJQtl7MjRHm5vdXuNtmMRCyY562d ZvHc+llaUoRB8vCuovZB9j3xShuqDVdSSCUsdB+NTGSZenJxLU9EWgw0rUB8M9Jj5SMjGXlcOFF1J dbnZlWIw==; Received: from authenticated user by zero.zsh.org with local id 1mCkOu-000KNs-IU; Sun, 08 Aug 2021 15:07:44 +0000 Authentication-Results: zsh.org; iprev=pass (relay1-d.mail.gandi.net) smtp.remote-ip=217.70.183.193; dmarc=none header.from=chazelas.org; arc=none Received: from relay1-d.mail.gandi.net ([217.70.183.193]:16905) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1mCkOF-000JhN-Vu; Sun, 08 Aug 2021 15:07:04 +0000 Received: (Authenticated sender: stephane@chazelas.org) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 25A36240003; Sun, 8 Aug 2021 15:07:02 +0000 (UTC) Date: Sun, 8 Aug 2021 16:07:02 +0100 From: Stephane Chazelas To: Ray Andrews Cc: zsh-users@zsh.org Subject: Re: file globbing Message-ID: <20210808150702.byts5nk52c4wdanx@chazelas.org> Mail-Followup-To: Ray Andrews , zsh-users@zsh.org References: <5bd2624d-86f4-fc9f-f57a-1e3b93a5fefb@eastlink.ca> <112137895.688578.1628177238255@mail2.virginmedia.com> <600156803.688994.1628177808803@mail2.virginmedia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: X-Seq: 26876 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: 2021-08-05 09:05:19 -0700, Ray Andrews: > On 2021-08-05 8:36 a.m., Peter Stephenson wrote: > > > On 05 August 2021 at 16:27 Peter Stephenson wrote: > > >=20 > > d,1^[[:digit:]]* > >=20 > >=20 > Cool.=C2=A0 I thought zsh always used ' [:digit:]' not the double bracket= form.=C2=A0 [...] I would avoid [[:digit:]] in zsh globs / patterns especially for input validation. [:digit:] within a bracket expression is a POSIX character class, it is a POSIX invention. It would be recognised, but within bracket expressions only by anything specified by POSIX and that uses shell filename patters or regular expressions (basic or extended) such as sh (for globs or case constructs), find (for -name/-path matching) for grep/sed/ed... [X[:digit:]] would match on any character that is either X or any character classified as decimal digit in the locale. What that matches in practice depends on the system and locale.=20 In 2016, someone pointed out to POSIX that isdigit() in the C standard was not locale dependent and matched on 0123456789 only (https://www.austingroupbugs.net/view.php?id=3D1078), so, to align with that future versions of the standard will restrict [:digit:] to match on 0123456789 only and will forbid to match on any other decimal digits. I wouldn't be surprised if that's later reverted again though as it's quite unintuitive / inconsistent. Still, there are systems where iswdigit() matches on a lot more than 0123456789 in some locales, and as a consequence, the [[:digit:]] of zsh globs and most other tools will too. For instance, on FreeBSD 12.2 and in a en_US.UTF-8 locale, [[:digit:]] matches on 0123456789=D9=A0=D9=A1=D9=A2=D9=A3=D9=A4=D9=A5=D9=A6=D9=A7=D9=A8=D9=A9=DB= =B0=DB=B1=DB=B2=DB=B3=DB=B4=DB=B5=DB=B6=DB=B7=DB=B8=DB=B9=DF=80=DF=81=DF=82= =DF=83=DF=84=DF=85=DF=86=DF=87=DF=88=DF=89=E0=A5=A6=E0=A5=A7=E0=A5=A8=E0=A5= =A9=E0=A5=AA=E0=A5=AB=E0=A5=AC=E0=A5=AD=E0=A5=AE=E0=A5=AF=E0=A7=A6=E0=A7=A7= =E0=A7=A8=E0=A7=A9=E0=A7=AA=E0=A7=AB=E0=A7=AC=E0=A7=AD=E0=A7=AE=E0=A7=AF=E0= =A9=A6=E0=A9=A7=E0=A9=A8=E0=A9=A9=E0=A9=AA=E0=A9=AB=E0=A9=AC=E0=A9=AD=E0=A9= =AE=E0=A9=AF=E0=AB=A6=E0=AB=A7=E0=AB=A8=E0=AB=A9=E0=AB=AA=E0=AB=AB=E0=AB=AC= =E0=AB=AD=E0=AB=AE=E0=AB=AF=E0=AD=A6=E0=AD=A7=E0=AD=A8=E0=AD=A9=E0=AD=AA=E0= =AD=AB=E0=AD=AC=E0=AD=AD=E0=AD=AE=E0=AD=AF=E0=AF=A6=E0=AF=A7=E0=AF=A8=E0=AF= =A9=E0=AF=AA=E0=AF=AB=E0=AF=AC=E0=AF=AD=E0=AF=AE=E0=AF=AF=E0=B1=A6=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7=91=E1=A7=92=E1=A7=93=E1=A7=94=E1=A7=95=E1=A7=96= =E1=A7=97=E1=A7=98=E1=A7=99=E1=AA=80=E1=AA=81=E1=AA=82=E1=AA=83=E1=AA=84=E1= =AA=85=E1=AA=86=E1=AA=87=E1=AA=88=E1=AA=89=E1=AA=90=E1=AA=91=E1=AA=92=E1=AA= =93=E1=AA=94=E1=AA=95=E1=AA=96=E1=AA=97=E1=AA=98=E1=AA=99=E1=AD=90=E1=AD=91= =E1=AD=92=E1=AD=93=E1=AD=94=E1=AD=95=E1=AD=96=E1=AD=97=E1=AD=98=E1=AD=99=E1= =AE=B0=E1=AE=B1=E1=AE=B2=E1=AE=B3=E1=AE=B4=E1=AE=B5=E1=AE=B6=E1=AE=B7=E1=AE= =B8=E1=AE=B9=E1=B1=80=E1=B1=81=E1=B1=82=E1=B1=83=E1=B1=84=E1=B1=85=E1=B1=86= =E1=B1=87=E1=B1=88=E1=B1=89=E1=B1=90=E1=B1=91=E1=B1=92=E1=B1=93=E1=B1=94=E1= =B1=95=E1=B1=96=E1=B1=97=E1=B1=98=E1=B1=99=EA=98=A0=EA=98=A1=EA=98=A2=EA=98= =A3=EA=98=A4=EA=98=A5=EA=98=A6=EA=98=A7=EA=98=A8=EA=98=A9=EA=A3=90=EA=A3=91= =EA=A3=92=EA=A3=93=EA=A3=94=EA=A3=95=EA=A3=96=EA=A3=97=EA=A3=98=EA=A3=99=EA= =A4=80=EA=A4=81=EA=A4=82=EA=A4=83=EA=A4=84=EA=A4=85=EA=A4=86=EA=A4=87=EA=A4= =88=EA=A4=89=EA=A7=90=EA=A7=91=EA=A7=92=EA=A7=93=EA=A7=94=EA=A7=95=EA=A7=96= =EA=A7=97=EA=A7=98=EA=A7=99=EA=A7=B0=EA=A7=B1=EA=A7=B2=EA=A7=B3=EA=A7=B4=EA= =A7=B5=EA=A7=B6=EA=A7=B7=EA=A7=B8=EA=A7=B9=EA=A9=90=EA=A9=91=EA=A9=92=EA=A9= =93=EA=A9=94=EA=A9=95=EA=A9=96=EA=A9=97=EA=A9=98=EA=A9=99=EA=AF=B0=EA=AF=B1= =EA=AF=B2=EA=AF=B3=EA=AF=B4=EA=AF=B5=EA=AF=B6=EA=AF=B7=EA=AF=B8=EA=AF=B9=EF= =BC=90=EF=BC=91=EF=BC=92=EF=BC=93=EF=BC=94=EF=BC=95=EF=BC=96=EF=BC=97=EF=BC= =98=EF=BC=99=F0=90=92=A0=F0=90=92=A1=F0=90=92=A2=F0=90=92=A3=F0=90=92=A4=F0= =90=92=A5=F0=90=92=A6=F0=90=92=A7=F0=90=92=A8=F0=90=92=A9=F0=90=B4=B0=F0=90= =B4=B1=F0=90=B4=B2=F0=90=B4=B3=F0=90=B4=B4=F0=90=B4=B5=F0=90=B4=B6=F0=90=B4= =B7=F0=90=B4=B8=F0=90=B4=B9=F0=91=81=A6=F0=91=81=A7=F0=91=81=A8=F0=91=81=A9= =F0=91=81=AA=F0=91=81=AB=F0=91=81=AC=F0=91=81=AD=F0=91=81=AE=F0=91=81=AF=F0= =91=83=B0=F0=91=83=B1=F0=91=83=B2=F0=91=83=B3=F0=91=83=B4=F0=91=83=B5=F0=91= =83=B6=F0=91=83=B7=F0=91=83=B8=F0=91=83=B9=F0=91=84=B6=F0=91=84=B7=F0=91=84= =B8=F0=91=84=B9=F0=91=84=BA=F0=91=84=BB=F0=91=84=BC=F0=91=84=BD=F0=91=84=BE= =F0=91=84=BF=F0=91=87=90=F0=91=87=91=F0=91=87=92=F0=91=87=93=F0=91=87=94=F0= =91=87=95=F0=91=87=96=F0=91=87=97=F0=91=87=98=F0=91=87=99=F0=91=8B=B0=F0=91= =8B=B1=F0=91=8B=B2=F0=91=8B=B3=F0=91=8B=B4=F0=91=8B=B5=F0=91=8B=B6=F0=91=8B= =B7=F0=91=8B=B8=F0=91=8B=B9=F0=91=91=90=F0=91=91=91=F0=91=91=92=F0=91=91=93= =F0=91=91=94=F0=91=91=95=F0=91=91=96=F0=91=91=97=F0=91=91=98=F0=91=91=99=F0= =91=93=90=F0=91=93=91=F0=91=93=92=F0=91=93=93=F0=91=93=94=F0=91=93=95=F0=91= =93=96=F0=91=93=97=F0=91=93=98=F0=91=93=99=F0=91=99=90=F0=91=99=91=F0=91=99= =92=F0=91=99=93=F0=91=99=94=F0=91=99=95=F0=91=99=96=F0=91=99=97=F0=91=99=98= =F0=91=99=99=F0=91=9B=80=F0=91=9B=81=F0=91=9B=82=F0=91=9B=83=F0=91=9B=84=F0= =91=9B=85=F0=91=9B=86=F0=91=9B=87=F0=91=9B=88=F0=91=9B=89=F0=91=9C=B0=F0=91= =9C=B1=F0=91=9C=B2=F0=91=9C=B3=F0=91=9C=B4=F0=91=9C=B5=F0=91=9C=B6=F0=91=9C= =B7=F0=91=9C=B8=F0=91=9C=B9=F0=91=A3=A0=F0=91=A3=A1=F0=91=A3=A2=F0=91=A3=A3= =F0=91=A3=A4=F0=91=A3=A5=F0=91=A3=A6=F0=91=A3=A7=F0=91=A3=A8=F0=91=A3=A9=F0= =91=B1=90=F0=91=B1=91=F0=91=B1=92=F0=91=B1=93=F0=91=B1=94=F0=91=B1=95=F0=91= =B1=96=F0=91=B1=97=F0=91=B1=98=F0=91=B1=99=F0=91=B5=90=F0=91=B5=91=F0=91=B5= =92=F0=91=B5=93=F0=91=B5=94=F0=91=B5=95=F0=91=B5=96=F0=91=B5=97=F0=91=B5=98= =F0=91=B5=99=F0=91=B6=A0=F0=91=B6=A1=F0=91=B6=A2=F0=91=B6=A3=F0=91=B6=A4=F0= =91=B6=A5=F0=91=B6=A6=F0=91=B6=A7=F0=91=B6=A8=F0=91=B6=A9=F0=96=A9=A0=F0=96= =A9=A1=F0=96=A9=A2=F0=96=A9=A3=F0=96=A9=A4=F0=96=A9=A5=F0=96=A9=A6=F0=96=A9= =A7=F0=96=A9=A8=F0=96=A9=A9=F0=96=AD=90=F0=96=AD=91=F0=96=AD=92=F0=96=AD=93= =F0=96=AD=94=F0=96=AD=95=F0=96=AD=96=F0=96=AD=97=F0=96=AD=98=F0=96=AD=99=F0= =9D=9F=8E=F0=9D=9F=8F=F0=9D=9F=90=F0=9D=9F=91=F0=9D=9F=92=F0=9D=9F=93=F0=9D= =9F=94=F0=9D=9F=95=F0=9D=9F=96=F0=9D=9F=97=F0=9D=9F=98=F0=9D=9F=99=F0=9D=9F= =9A=F0=9D=9F=9B=F0=9D=9F=9C=F0=9D=9F=9D=F0=9D=9F=9E=F0=9D=9F=9F=F0=9D=9F=A0= =F0=9D=9F=A1=F0=9D=9F=A2=F0=9D=9F=A3=F0=9D=9F=A4=F0=9D=9F=A5=F0=9D=9F=A6=F0= =9D=9F=A7=F0=9D=9F=A8=F0=9D=9F=A9=F0=9D=9F=AA=F0=9D=9F=AB=F0=9D=9F=AC=F0=9D= =9F=AD=F0=9D=9F=AE=F0=9D=9F=AF=F0=9D=9F=B0=F0=9D=9F=B1=F0=9D=9F=B2=F0=9D=9F= =B3=F0=9D=9F=B4=F0=9D=9F=B5=F0=9D=9F=B6=F0=9D=9F=B7=F0=9D=9F=B8=F0=9D=9F=B9= =F0=9D=9F=BA=F0=9D=9F=BB=F0=9D=9F=BC=F0=9D=9F=BD=F0=9D=9F=BE=F0=9D=9F=BF=F0= =9E=A5=90=F0=9E=A5=91=F0=9E=A5=92=F0=9E=A5=93=F0=9E=A5=94=F0=9E=A5=95=F0=9E= =A5=96=F0=9E=A5=97=F0=9E=A5=98=F0=9E=A5=99 All decimal digits, some variations on the 0123456789 Arabic ones, and some other decimal digits in some other scripts. [0-9] itself, in general, is even worse. Not two systems or utilities or library functions and version thereof agree on what characters are ranked between 0 and 9. It could even match on sequences of characters (collating elements). That's not the case of zsh globs though where [0-9] only matches on 0123456789, as ranges in zsh are based on the wide char value of the characters (or byte value if the multibyte option is off), and for those 0123456789 characters specifically, in practice, the wide char values are consecutive and in that order regardless of the locale and system. Beware though that it only applies to zsh globs. It doesn't apply to [0-9] in regexps which use the system's extended regexps matching functions (or pcre with the rematchpcre option; see also \d there). The only thing guaranteed to match only 0123456789 regardless of locale and system is [0123456789], do not use [[:digit:]] or \d for that. In zsh, you can use [0-9] but only with globs. [[ $d =3D [0-9] ]] && echo is one of 0123456789 is correct (in zsh, not in bash / ksh93) [[ $d =3D~ '^[0-9]$' && echo is one of 0123456789 is not (at least on some systems/locales). With set -o rematchpcre [[ $d =3D~ '^[0-9]\Z' && echo is one of 0123456789 should be OK (so would the same with \d, though I wouldn't trust it as it could vary with the version and what flags are passed to the matcher as \d can be told to match other digits under some circumstances). Also beware re matching doesn't work properly on non-text. See also https://www.mail-archive.com/bug-bash@gnu.org/msg25885.html for a glimpse at the (more messier) situation in the bash shell. --=20 Stephane