From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-users@zsh.org
Subject: Re: somehow offtopic: looping filenames
Date: Mon, 20 Feb 2012 19:38:10 +0100 [thread overview]
Message-ID: <87boot9wq5.fsf@ft.bewatermyfriend.org> (raw)
In-Reply-To: <20120220181650.GA11514@solfire> (meino cramer's message of "Mon, 20 Feb 2012 19:16:50 +0100")
meino.cramer@gmx.de wrote:
> I habe a loop like this:
>
> for fn *
> do
> flac $fn
> done
>
> Unfortunately, some file have 'illegal' filenames like
>
> 20120220-_-19db.wav
> or
> 20120220 sensor10 up.wav
>
>
> which parts flac sees as unknown commmand options or as
> two file and the loop fails.
So, you're setting `sh_word_split'? Or are you using another shell?
This should work in every shell:
for i in ./*; do
flac "$i"
done
The ./ makes sure the file name cannot start in a dash, which many
applications would otherwise take as an option name. The "$i" makes sure
the shell sees the variable contents as one word. Zsh does that with
unquoted parameters by default. You'll have to set the `sh_word_split'
option to get a more bourne-shell-like behaviour.
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
next prev parent reply other threads:[~2012-02-20 18:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 18:16 meino.cramer
2012-02-20 18:38 ` Frank Terbeck [this message]
2012-02-20 19:05 ` Bart Schaefer
2012-02-21 12:35 ` Stephen Blott
2012-02-21 13:35 ` Frank Terbeck
2012-02-22 23:41 ` Mark van Dijk
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=87boot9wq5.fsf@ft.bewatermyfriend.org \
--to=ft@bewatermyfriend.org \
--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).