zsh-users
 help / color / mirror / code / Atom feed
From: Roman Neuhauser <neuhauser@sigpipe.cz>
To: Nikolai Weibull <now@disu.se>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Equivalent of set -- *(DN) in sh
Date: Sun, 18 Jan 2015 21:32:13 +0100	[thread overview]
Message-ID: <20150118203213.GH979@isis.sigpipe.cz> (raw)
In-Reply-To: <CADdV=MtVmkVVgCvjf_wj13VnP0C3O5twuRPeGDpq_h53pUkzoA@mail.gmail.com>

# now@disu.se / 2015-01-18 20:43:55 +0100:
> On Sun, Jan 18, 2015 at 8:07 PM, Roman Neuhauser <neuhauser@sigpipe.cz> wrote:
> > # now@disu.se / 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


  reply	other threads:[~2015-01-18 20:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-18 18:28 Nikolai Weibull
2015-01-18 19:07 ` Roman Neuhauser
2015-01-18 19:43   ` Nikolai Weibull
2015-01-18 20:32     ` Roman Neuhauser [this message]
2015-01-18 19:31 ` ZyX
2015-01-18 19:46   ` Nikolai Weibull
2015-01-18 20:46 ` Eric Cook
2015-01-19 15:51   ` ZyX
2015-01-19 15:55     ` ZyX
2015-01-19 16:02       ` ZyX
2015-01-19 16:16         ` ZyX
2015-01-19 21:44     ` Eric Cook
     [not found]     ` <54BD7ABB.5070501__36205.2317861982$1421704010$gmane$org@gmx.com>
2015-01-19 23:05       ` Stephane Chazelas
2015-01-22  7:44         ` Nikolai Weibull
     [not found]         ` <CADdV=MsvuSAQMJVsr17Y7g2Nfjy95CQ007opQqv-7=RHjgjaKw__35342.9068615243$1421913204$gmane$org@mail.gmail.com>
2015-01-22 15:21           ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150118203213.GH979@isis.sigpipe.cz \
    --to=neuhauser@sigpipe.cz \
    --cc=now@disu.se \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).