zsh-users
 help / color / mirror / Atom feed
* Multi-element zstat
@ 2021-09-22  0:51 Daniel Shahaf
  2021-09-23 22:39 ` Phil Pennock
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Shahaf @ 2021-09-22  0:51 UTC (permalink / raw)
  To: zsh-users

> tt(zstat )[ tt(-gnNolLtTrs) ] [ tt(-f) var(fd) ] \
>     [ tt(-H) var(hash) ] [ tt(-A) var(array) ] \
>     [ tt(-F) var(fmt) ]
>     [ tt(PLUS())var(element) ] [ var(file) ... ]
> A particular element may be selected by including its name
> preceded by a `tt(PLUS())' in the option list; only one element is allowed.
> The element may be shortened to any unique set of leading
> characters.  Otherwise, all elements will be shown for all files.

How about extending the syntax to permit specifying multiple elements,
in which case only those will be shown?  E.g., «zstat +uid:gid:mode
./foo» or «zstat +uid +gid +mode ./foo»?  The latter syntax would
necessitate an incompatible change notice in NEWS/README (because «zstat
+mode +foo» does stat("+foo"), exactly as the docstring promises).  The
output of the example invocation would be as follows (assuming -o is
also passed for sanity):
.
	mode    0100644
	uid     1000
	gid     1000

Looping over the one-element syntax isn't convenient when multiple file
targets are passed.  Ditto grepping the output.

Just looking for consensus on the direction at this point; not planning
to implement this immediately.

Cheers,

Daniel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Multi-element zstat
  2021-09-22  0:51 Multi-element zstat Daniel Shahaf
@ 2021-09-23 22:39 ` Phil Pennock
  2021-09-26  6:54   ` Daniel Shahaf
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Pennock @ 2021-09-23 22:39 UTC (permalink / raw)
  To: zsh-users

On 2021-09-22 at 00:51 +0000, Daniel Shahaf wrote:
> How about extending the syntax to permit specifying multiple elements,
> in which case only those will be shown?

> Looping over the one-element syntax isn't convenient when multiple file
> targets are passed.  Ditto grepping the output.
> 
> Just looking for consensus on the direction at this point; not planning
> to implement this immediately.

No objection, but since you only list two of the approaches, have you
considered whether or not using the -H option will suit your needs?

for F in *(D.); do
  zstat -nH st -- "$F"
  print "$st[mode] $st[uid] $st[gid] $st[name]"
done

-Phil


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Multi-element zstat
  2021-09-23 22:39 ` Phil Pennock
@ 2021-09-26  6:54   ` Daniel Shahaf
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2021-09-26  6:54 UTC (permalink / raw)
  To: Phil Pennock, zsh-users

Phil Pennock wrote on Thu, 23 Sep 2021 22:39 +00:00:
> On 2021-09-22 at 00:51 +0000, Daniel Shahaf wrote:
>> How about extending the syntax to permit specifying multiple elements,
>> in which case only those will be shown?
>
>> Looping over the one-element syntax isn't convenient when multiple file
>> targets are passed.  Ditto grepping the output.
>> 
>> Just looking for consensus on the direction at this point; not planning
>> to implement this immediately.
>
> No objection, but since you only list two of the approaches, have you
> considered whether or not using the -H option will suit your needs?
>
> for F in *(D.); do
>   zstat -nH st -- "$F"
>   print "$st[mode] $st[uid] $st[gid] $st[name]"
> done

I haven't.  Thanks.  It certainly beats both of the workarounds
I came up with.  Adding the syntactic sugar might still have value; I'll
see what I think the next time I run into this in my day-to-day uses.

Thanks again.

Daniel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-26  6:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-22  0:51 Multi-element zstat Daniel Shahaf
2021-09-23 22:39 ` Phil Pennock
2021-09-26  6:54   ` Daniel Shahaf

zsh-users

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/zsh-users

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-users zsh-users/ https://inbox.vuxu.org/zsh-users \
		zsh-users@zsh.org
	public-inbox-index zsh-users

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git