From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9449 invoked by alias); 22 Jun 2015 20:41:31 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20268 Received: (qmail 23873 invoked from network); 22 Jun 2015 20:41:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 Date: Mon, 22 Jun 2015 22:31:31 +0200 From: Roman Neuhauser To: lists@necoro.eu Cc: zsh-users@zsh.org Subject: Re: ls -l *(/)... Message-ID: <20150622203131.GB8473@isis.sigpipe.cz> References: <20150622031753.GA4342@solfire> <55879C40.9020102@necoro.eu> <20150622163654.GB4560@solfire> <55884CFC.6010803@necoro.eu> <20150622190837.GA9569@ramirez.u-strasbg.fr> <5588616C.5090109@necoro.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5588616C.5090109@necoro.eu> User-Agent: Mutt/1.5.23 (2014-03-12) # 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