zsh+OSX: how to cope w spaces in fnames?
zsh+OSX: how to cope w spaces in fnames?
am 27.11.2007 23:59:38 von kj
I recently switched to OS X for my home computer. One recurrent
source of headaches is the proliferation in OS X of filenames with
embedded spaces. This means that many of my habitual shell
interaction practices fail; e.g. anything like
% for i ( *.mp3 ) frobnicate $i
will fail with errors like
frobnicate: La: No such file or directory
frobnicate: Cucaracha.mp3: No such file or directory
etc.
I have resisted the temptation to write a function that will rename
all the files in the current directory, replacing spaces with
underscores, because I fear that such a "destructive" procedure is
precisely the kind that I should not be doing too easily; invariably
*somewhere* there will be the proverbial File Whose Name Should
Not Be Changed, etc., etc. Weeks later, some program begins to
crash inexplicably, leading to loss of productivity, alcoholism,
foreclosure, divorce, suicide, the usual story... So, DON'T GO
THERE, in flashing neon lights...
Is there anything else I could do to regain my shell interaction
fluency in this environment?
TIA!
kj
--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
Re: zsh+OSX: how to cope w spaces in fnames?
am 28.11.2007 00:07:53 von Dan Mercer
"kj" wrote in message news:fii7gq$erf$1@reader1.panix.com...
:
:
: I recently switched to OS X for my home computer. One recurrent
: source of headaches is the proliferation in OS X of filenames with
: embedded spaces. This means that many of my habitual shell
: interaction practices fail; e.g. anything like
:
: % for i ( *.mp3 ) frobnicate $i
% for i ( *.mp3 ) frobnicate "$i"
Good practice no matter what shell you're using
Dan Mercer
:
: will fail with errors like
:
: frobnicate: La: No such file or directory
: frobnicate: Cucaracha.mp3: No such file or directory
:
: etc.
:
: I have resisted the temptation to write a function that will rename
: all the files in the current directory, replacing spaces with
: underscores, because I fear that such a "destructive" procedure is
: precisely the kind that I should not be doing too easily; invariably
: *somewhere* there will be the proverbial File Whose Name Should
: Not Be Changed, etc., etc. Weeks later, some program begins to
: crash inexplicably, leading to loss of productivity, alcoholism,
: foreclosure, divorce, suicide, the usual story... So, DON'T GO
: THERE, in flashing neon lights...
:
: Is there anything else I could do to regain my shell interaction
: fluency in this environment?
:
: TIA!
:
: kj
:
: --
: NOTE: In my address everything before the first period is backwards;
: and the last period, and everything after it, should be discarded.
Re: zsh+OSX: how to cope w spaces in fnames?
am 28.11.2007 00:10:45 von Christian Schneider
Thus spake kj (socyl@987jk.com.invalid):
> I recently switched to OS X for my home computer. One recurrent
> source of headaches is the proliferation in OS X of filenames with
> embedded spaces. This means that many of my habitual shell
> interaction practices fail; e.g. anything like
>
> % for i ( *.mp3 ) frobnicate $i
>
> will fail with errors like
>
> frobnicate: La: No such file or directory
> frobnicate: Cucaracha.mp3: No such file or directory
>
> etc.
[...]
Maybe »for i ( *.mp3 ) frobnicate "$i"«?
--
{ \|/ ______ \|/ Access denieded | Christian 'strcat' Schneider }
{ "@' / , . \ `@" Nah Nah Nah :p | http://www.strcat.de/ }
{ /__| \____/ |__\ | http://www.strcat.de/blog/ }
{ \___U__/ | http://strcat.de/chris.gpg }
Re: zsh+OSX: how to cope w spaces in fnames?
am 28.11.2007 10:04:52 von Stephane CHAZELAS
On Tue, 27 Nov 2007 22:59:38 +0000 (UTC), kj wrote:
>
>
> I recently switched to OS X for my home computer. One recurrent
> source of headaches is the proliferation in OS X of filenames with
> embedded spaces. This means that many of my habitual shell
> interaction practices fail; e.g. anything like
>
> % for i ( *.mp3 ) frobnicate $i
>
> will fail with errors like
>
> frobnicate: La: No such file or directory
> frobnicate: Cucaracha.mp3: No such file or directory
[...]
That should work with zsh as that's one of the biggest sh
misfeature that zsh fixed, unless you've configured zsh to
emulate other shells or explicitely set the "sh_word_split"
option (in which case you need to quote $i as others said).
What is possible is that the "frobnicate" command can't deal
with filenames with spaces. It's likely for instance if it's a
poorly written shell script.
--
Stephane