Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Equivalent of set -- *(DN) in sh
- X-seq: zsh-users 19743
- From: Roman Neuhauser <neuhauser@xxxxxxxxxx>
- To: Nikolai Weibull <now@xxxxxxx>
- Subject: Re: Equivalent of set -- *(DN) in sh
- Date: Sun, 18 Jan 2015 21:32:13 +0100
- Cc: Zsh Users <zsh-users@xxxxxxx>
- In-reply-to: <CADdV=MtVmkVVgCvjf_wj13VnP0C3O5twuRPeGDpq_h53pUkzoA@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADdV=MvMtwYczr82GeYkmVwTFCKgFcbgYS71XdnHZN_JqFqzTg@mail.gmail.com> <20150118190723.GG979@isis.sigpipe.cz> <CADdV=MtVmkVVgCvjf_wj13VnP0C3O5twuRPeGDpq_h53pUkzoA@mail.gmail.com>
# now@xxxxxxx / 2015-01-18 20:43:55 +0100:
> On Sun, Jan 18, 2015 at 8:07 PM, Roman Neuhauser <neuhauser@xxxxxxxxxx> wrote:
> > # now@xxxxxxx / 2015-01-18 19:28:42 +0100:
> >> Is there any way to get the equivalent of Zsh´s
> >>
> >> set -- *(DN)
> >>
> >> in sh? Most important here would be NULL_GLOB, as, by default, sh
> >> simply leaves the * if there are no files to match.
> >
> > set -- $(find .* * -maxdepth 0 -type d)
> >
> > does not handle names with spaces.
>
> Which is unsatisfactory, as $() isn´t in all versions of sh,
then use `find ...`, problem solved.
btw if your requirements are this stringent you would have done well
if you laid them out upfront.
> -maxdepth is GNU specific
it's not, at least all BSDs have it as well. again, what operating
systems do you need to support?
> and .* and * will be expanded by the shell, not by find
you can `find . -maxdepth 1 -mindepth 1`, but the paths will be prefixed
with "./". you could of ocurse append `| sed 's:..::'`.
OTOH, what's the problem with the shell expanding the globs?
if .* or * does not exist, sh leaves that there as-is, find cannot
chdir into it, and definitely won't print it.
> Oh, and who said anything about only including directories? ;-)
yeah, that was a brainfart, sorry.
--
roman
Messages sorted by:
Reverse Date,
Date,
Thread,
Author