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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16789 invoked from network); 27 Oct 2022 20:03:50 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 Oct 2022 20:03:50 -0000 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:Content-Transfer-Encoding: Content-Type:Subject:Cc:To:From:Date:References:In-Reply-To:Message-Id: Mime-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=I1a8elAGAqqcswX++Ah7UYphp2rhZRtoj/c4GH2CdHs=; b=Hb7Bpz44DdJh5D81En3Nsp9Tsz BN38ExnKy+5tVNv+XHoA5IqSS1ch4j4n3LcLpFWS/jr/NEE7VtwvR7fSQM9A7hwtKnVyxZTMnHXul GeiO1hfUPaHnN2DsnpKGcMOUzQLxzEpaA2li1d+yzDweqmLCwWU7Jw0Iw6uzMizy/qtL8eWP4A2s6 SoURCO4Pi3FnOAs6dSRZXCKlXOtn+oNbk9uiu6Vxn+46uzjMzqZnkiSeL+CxWpiJTzEViptM1Z3Hj sgcZxCCybvZHh5FLowN18tw1q21RoRXOvRSWMyjmZ9K4pNxOY6avBeNZfTg7x1xeS/W1vTMhySkl+ k45RBveQ==; Received: by zero.zsh.org with local id 1oo96T-000DpV-5c; Thu, 27 Oct 2022 20:03:49 +0000 Received: by zero.zsh.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1oo95k-000D7D-DD; Thu, 27 Oct 2022 20:03:04 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailauth.nyi.internal (Postfix) with ESMTP id EA1CA27C0054; Thu, 27 Oct 2022 16:02:59 -0400 (EDT) Received: from imap48 ([10.202.2.98]) by compute2.internal (MEProxy); Thu, 27 Oct 2022 16:02:59 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrtdeggddugeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepnfgr fihrvghntggvucggvghljoiiqhhuvgiiuceolhgrrhhrhihvseiishhhrdhorhhgqeenuc ggtffrrghtthgvrhhnpedvteekleeiheevvdetudehkedthedtjeegheejledufeeuffdu ueeggeejhfffffenucffohhmrghinhepshhouhhrtggvfhhorhhgvgdrihhonecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhihvodhm vghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudehudekjeejtdegqdduudelvd ejfeekhedqlhgrrhhrhihvpeepiihshhdrohhrghesfhgrshhtmhgrihhlrdgtohhm X-ME-Proxy: Feedback-ID: iaa214773:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id B573231A0062; Thu, 27 Oct 2022 16:02:58 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-1087-g968661d8e1-fm-20221021.001-g968661d8 Mime-Version: 1.0 Message-Id: <05065e8d-8bf7-4ca2-b89d-1151348cb30d@app.fastmail.com> In-Reply-To: <22b55ee0-ab85-1352-87a7-32dde5c7678d@eastlink.ca> References: <22b55ee0-ab85-1352-87a7-32dde5c7678d@eastlink.ca> Date: Thu, 27 Oct 2022 16:02:37 -0400 From: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= To: "Ray Andrews" Cc: zsh-users@zsh.org Subject: Re: glob executable vs. non executable Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 28280 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: On Thu, Oct 27, 2022, at 11:41 AM, Ray Andrews wrote: > I'm trying to break all 'real' files -- ignoring those weird 'special'=20 > files that linux makes -- into two groups: executables, which I take t= o=20 > be x-scripts, binaries and symlinks Symbolic links are generally not considered to be executable files. They may appear to have executable permissions, but those are usually ignored. What matters are the permissions of the targets. > vs. everything else, basically=20 > unx-scripts and plain text files. What about binary files that you cannot execute, like libraries, images, audio files, tarballs, etc.? > $=C2=A0 eval "all_unx=3D( (#i)$1(N.^*) )" There's almost certainly no need to use eval for this. If $1 contains a globbing pattern, then you can allow its value to be used as such like so: all_unx=3D( (#i)${~1}(N.^*) ) The ${~spec} form enables GLOB_SUBST for that substitution. https://zsh.sourceforge.io/Doc/Release/Expansion.html#index-GLOB_005fSUB= ST_002c-toggle > ... that seems to work for the later, the dot excludes symlinks but=20 > includes executables so: '^*' excludes those.=C2=A0 But what's the con= verse?=C2=A0=20 > I'm wanting: > > $=C2=A0=C2=A0 eval "all_x=3D( (#i)$1(N*@) )" > > ... but it's a bad pattern. It's not a bad pattern; the qualifiers are just impossible to satisfy. You are asking for regular executable files that are ALSO symbolic links. > I can append two searches, one for '*' the=20 > other for '@' but I'm betting there's a clean way of doing it. Strictly speaking, you could use a comma to separate the "*" and "@" qualifiers; this denotes a logical disjunction. (Juxtaposition indicates a conjunction.) all_unx=3D( (#i)${~1}(N*,@) ) However, as I said earlier, it is not useful to consider symbolic links "executable", so this result does not make any sense. You probably want to find executables and *symbolic links that point to executables*. This can be done with the "-" qualifier, which causes the subsequent qualifiers to operate on symbolic links' targets instead of on the links themselves. all_unx=3D( (#i)${~1}(N-*) ) > Basically real files that whence is interested in vs. real files she i= s=20 > not interested in.=C2=A0 Given that these glob qualifiers have a quite=20 > astonishing power, it seems puzzling that ... well, I shouldn't presum= e=20 > it isn't already there, but in my mind: > > $=C2=A0=C2=A0 eval "all_matches=3D( (#i)$1(NX )" > > ... anything whence finds, anything executable that is a file. Using "*" with "-" more or less covers this. > Oh, and=20 > while I'm imagining new glob qualifiers, how about 'T': any text file,=20 > (un)executable script or just a cookie recipe but made of readable tex= t. (1) Whether a file is a "text file" is a characteristic of its contents and is not appropriate for a glob qualifier. (2) Determining whether a file is "text" is more complicated than you seem to think. (3) If you have a utility or some code that does that to your satisfaction, you can use it to filter the globbing results via the "e" qualifier. (4) The "T" qualifier is already in use. --=20 vq