From: Roman Neuhauser <neuhauser@sigpipe.cz>
To: lists@necoro.eu
Cc: zsh-users@zsh.org
Subject: Re: ls -l *(/)...
Date: Mon, 22 Jun 2015 22:31:31 +0200 [thread overview]
Message-ID: <20150622203131.GB8473@isis.sigpipe.cz> (raw)
In-Reply-To: <5588616C.5090109@necoro.eu>
# lists@necoro.eu / 2015-06-22 21:26:36 +0200:
> Am 22.06.2015 um 21:08 schrieb Marc Chantreux:
> >> Of course you can also iterate over them:
> >> for f in */*; echo $(basename $f)
> >
> > print -l */*:t
>
> Thanks, but I just intended the for-loop as a small one-line example :).
> Because I thought that the original intention might have been something
> along the lines of
>
> for f in `ls */*`; ...
that's actually an antipattern. first, the largely inconsequential
things: it forks an extra shell (and ls), and it's longer than
for f in */*; ...
second, and this is the dealbreaker, pathnames with IFS characters in
them are going to break this code horribly.
% touch foo bar omg\ wtf
% for f in *; do print $f; done
bar
foo
omg wtf
% for f in `ls *`; do print $f; done
bar
foo
omg
wtf
> I write longer zsh-scripts so seldom that I always forget what all
> those magic letters are for. So I need either a lengthy comment or I
> always have to read zsh manpages when I happen to stumble of the piece
> in question again.
the absolutee basics are quite easy to remember:
:t - tail
:h - head
:r - root
:a - absolute path
:A - absolute path, the grown-up version (uses realpath(3))
--
roman
next prev parent reply other threads:[~2015-06-22 20:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 3:17 Meino.Cramer
2015-06-22 5:25 ` lists
[not found] ` <20150622163654.GB4560@solfire>
2015-06-22 17:59 ` lists
2015-06-22 18:30 ` Bart Schaefer
2015-06-22 21:28 ` Bernd Steinhauser
2015-06-22 19:08 ` Marc Chantreux
2015-06-22 19:26 ` lists
2015-06-22 20:31 ` Roman Neuhauser [this message]
2015-06-23 11:30 ` Marc Chantreux
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=20150622203131.GB8473@isis.sigpipe.cz \
--to=neuhauser@sigpipe.cz \
--cc=lists@necoro.eu \
--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).