From: kj on


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.
From: Dan Mercer on

"kj" <socyl(a)987jk.com.invalid> wrote in message news:fii7gq$erf$1(a)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.


From: Christian Schneider on
Thus spake kj (socyl(a)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 }
From: Stephane Chazelas on
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