Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] coding practice in examples (-- with globs mostly)
- X-seq: zsh-workers 45177
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: [PATCH] coding practice in examples (-- with globs mostly)
- Date: Wed, 1 Jan 2020 12:00:09 +0000
- In-reply-to: <20191231171638.en6olco722w4ldcc@tarpaulin.shahaf.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20191231091618.v2erkblkwkiy3i5a@chaz.gmail.com> <20191231171638.en6olco722w4ldcc@tarpaulin.shahaf.local2>
2019-12-31 17:16:38 +0000, Daniel Shahaf:
[...]
> Suggest not to mention the solution before the problem:
>
> +Note: if the list of arguments is empty, tt(print -l) will still output one
> +empty line. To print a possibly-empty list of arguments one per line, use
> +tt(print -C1), as in `tt(print -rC1 -- "$list[@]")'.
[...]
Thanks for the feedback. Yes, that works for me.
> > {+++ b/Doc/Zsh/contrib.yo+}
> > @@ -4422,10 +4422,11 @@ For example, to get a long tt(ls) listing of all plain files in the
> > current directory or its subdirectories:
> >
> > example(autoload -U zargs
> > zargs -- **/*(.) -- ls [--l)-] {+-ld --)+}
> >
> > Note that `tt(-)tt(-)' is used both to mark the end of the var(option)
> > list and to mark the end of the var(input) [-list,-] {+list (and here also to mark
> > the end of the option list for tt(ls)),+} so it must appear twice
> > whenever the var(input) list may be empty. If there is guaranteed to be
> > at least one var(input) and the first var(input) does not begin with a
> > `tt(-)', then the first `tt(-)tt(-)' may be omitted.
>
> I think the text could be a little hard to follow, since there are three
> «--» but it talks about "both" and then mentions the third in an
> afterthought. Would you prefer to change the incumbent text as well?
> You're not limited to adding parentheticals.
I see what you mean. How about something like:
zargs -- **/*(.) -- ls -ld --
The first and third occurrences of -- are used to mark the end
of options for zargs and ls respectively to guard against
filenames starting with -, while the second is used to separate
the list of files from the command to run.
The first -- would also be needed if there was a chance the list
might be empty as in:
zargs -r -- ./*.back(#qN) -- rm -f
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author