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,NICE_REPLY_A,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 29890 invoked from network); 27 Oct 2022 21:45:19 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 Oct 2022 21:45:19 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1666907119; b=OiM1P9NsvHz7veR6Y7uqma0k72wu0ulLVgcFHd0Lok31V6zkAu2k7tGU+AjMS3aDxne+eomL/+ 6EJ4yuxaPN8BRUsSvHCaK7m1JJvLmU3+r5QJweuZpTSYRwyrKDrP7oQmmc40qBl3Kk+lGHwQpu i6ld1M9RTdoMDif6rTU/j0MB3FWnm8zG+d4LMgNWafo+7ofEZlf6+Vi6mw7bU+9BoXHCkkJZfJ 2kHnHt/B61b3AuuaUJ050SucmEv8bh0SoQggKkFqNghBsYusaJbnPGgL1Xza4Bha2AqDLJtySg NDFq+JjnY8gXWe34whAAnSC7cXjKDDSxDHh6O/1684AIeg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1666907119; bh=aETSF7ZpWoxYPfR7HHMyKlHrIB33V6K3HQcXgv7XP/E=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID:DKIM-Signature; b=KTPS+L+8Cg4vvTwOe2zfH49/B0n7yePet6Jw1sqYDR240rXYKbI3PzWVPxUweOjzHSzI5cPXKJ 7cTSpZmezyYPYZMls05h/okoH4N0Xk6QlnHD42aVtNCZ6sKOjPbhahMzpDBYVxbHiivrPk9JhB C5RxNoV4Zy/4peP7z/SEFuPZa9td6hEocXgx1hPRHalYMp11fmoWVfZ6Z2UU1e2M8rTCvxVQLh Cjquz4cQXNsRFS0q9OprG95A7ZhOi/+zeiHeqQshX9KCST7kTt52lTnEBebYE+vxkIYIUZeKDS 49g2dq56BQvBOSHOcH3HsaMygqOc1FAtw1SjemWJzfMT4w==; 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:In-reply-to:From:References:To:Subject:MIME-version:Date: Message-id:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=WRx0JOQQ67w12IYyI1CK1g88wXM1KeGNZnnSSyUyIbY=; b=j0gQ8EMCTuATm3lSpDlDMf1Vvv wwL490A+2I7101ewscgkcDeV7gKUQBF6DTcM53fSLHu3NIvSyPPcID+NtcEuGlLJte54hgzvqMWb0 +JPgDwRuTHeA8d5GVw3iXY43kjbdnljW2VB0wYaQrOWX2823ZyyxN1/28EAdzeb+8MSAIM24MIKCW 0s6c8eqOISkBm4pJQWC07AADPengfyl+0HB6aBTjlH/OcoE3dZ42G2a8UnF7Aj7wlP2Fun7sVfHxQ 1fX9JJ8rptv+jhADjrxj+gN+W+jn2ex7J7/+jcrER3ejfsimpxtGN2IAzkEZqL/2gqIlhB4oUNk3m sph0XXWA==; Received: by zero.zsh.org with local id 1ooAgg-000HEk-MB; Thu, 27 Oct 2022 21:45:18 +0000 Authentication-Results: zsh.org; iprev=pass (mta04.eastlink.ca) smtp.remote-ip=24.224.136.10; dmarc=none header.from=eastlink.ca; arc=none Received: from mta04.eastlink.ca ([24.224.136.10]:54032) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1ooAg0-000GVG-4M; Thu, 27 Oct 2022 21:44:37 +0000 Received: from csp01.eastlink.ca ([71.7.199.166]) by mta04.eastlink.ca (Oracle Communications Messaging Server 8.0.2.2.20180531 64bit (built May 31 2018)) with ESMTPS id <0RKF00BK9FH0NMQ1@mta04.eastlink.ca> for zsh-users@zsh.org; Thu, 27 Oct 2022 18:44:34 -0300 (ADT) Received: from [192.168.0.2] ([24.207.18.108]) by Eastlink with ESMTPSA id oAfyoRVeeIeZVoAfyoG6KW; Thu, 27 Oct 2022 18:44:34 -0300 X-Authority-Analysis: v=2.4 cv=Meqq+bzf c=1 sm=1 tr=0 ts=635afbc2 a=xN66ZtSbq5jdJYpBp7G/jQ==:117 a=xN66ZtSbq5jdJYpBp7G/jQ==:17 a=IkcTkHD0fZMA:10 a=aWU6azGIEqAL7bab2xYA:9 a=QEXdDO2ut3YA:10 X-Vade-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrtdehgddtvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfgtefuvffnkffpmfdpqfgfvfenuceurghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtfeejnecuhfhrohhmpeftrgihucetnhgurhgvfihsuceorhgrhigrnhgurhgvfihssegvrghsthhlihhnkhdrtggrqeenucggtffrrghtthgvrhhnpeeitdejffevgfdtheeggfetkeeugeegieetuddtvddvudetteffvdevlefgueekudenucfkphepvdegrddvtdejrddukedruddtkeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvgedrvddtjedrudekrddutdekpdhhvghloheplgduledvrdduieekrddtrddvngdpmhgrihhlfhhrohhmpehrrgihrghnughrvgifshesvggrshhtlhhinhhkrdgtrgdpnhgspghrtghpthhtohepvddprhgtphhtthhopeerredprhgtphhtthhopeiishhhqdhushgvrhhsseiishhhrdhorhhgpdhgvghtqdgkihhprfgrshhsfigupehtrhhuvg X-Vade-Score: 0 X-Vade-State: 0 X-EL-AUTH: rayandrews@eastlink.ca Message-id: Date: Thu, 27 Oct 2022 14:44:33 -0700 MIME-version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: glob executable vs. non executable Content-language: en-US To: zsh-users@zsh.org References: <22b55ee0-ab85-1352-87a7-32dde5c7678d@eastlink.ca> <05065e8d-8bf7-4ca2-b89d-1151348cb30d@app.fastmail.com> From: Ray Andrews In-reply-to: <05065e8d-8bf7-4ca2-b89d-1151348cb30d@app.fastmail.com> Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 8bit X-Seq: 28281 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 2022-10-27 13:02, Lawrence Velázquez wrote: > What about binary files that you cannot execute, like libraries, > images, audio files, tarballs, etc.? Yeah, I'm trying to cover all the possibilities.  'file' seems the most informative but even then there's more to say. > all_unx=( (#i)${~1}(N.^*) ) > > The ${~spec} form enables GLOB_SUBST for that substitution. Thanks, that handles it. > > 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. Ah! It's a test in series not in parallel.  I thought it was an OR, but it's an AND. > Strictly speaking, you could use a comma to separate the "*" and > "@" qualifiers; this denotes a logical disjunction. (Juxtaposition > indicates a conjunction.) > > all_unx=( (#i)${~1}(N*,@) ) > Very good.  I couldn't find any documentation on that. > However, as I said earlier, it is not useful to consider symbolic > links "executable" In my head the word might be 'actionable'.  Type some word at the prompt and press ENTER and sometimes something happens.  What I'm trying to nail down is all the possibilities and what sorts of species they can be.  In that frame of mind, a symlink is actionable so I consider it in the same category as any other actionable word. > , 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=( (#i)${~1}(N-*) ) > > Using "*" with "-" more or less covers this. Excellent, this gives me bones to chew on.  Fantastic power there if I can learn to use it. > > (1) Whether a file is a "text file" is a characteristic of its > contents and is not appropriate for a glob qualifier. Quite right.  I see it the moment you say it.  Different job. > (2) Determining whether a file is "text" is more complicated than > you seem to think. I know it.  'file' seems to use three separate tests.  So, come to think of it, that's a difficult thing to ask of the shell.  One might suppose it's easy but it ain't. > (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. ... just a 'for instance'.  But I see now that this is hardly the shell's business and even if it was, it would be one of those conditional expressions: > [ -T "$some_file" ] && echo "That does appear to be a text file but don't be too sure." < Anyway my function works well and I rely on it, but there's always the next little gotcha. Thanks Lawrence, you guys are so informative.  Learning zsh by myself would be next to impossible.