Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'IMPORTANT: Spaces need to be escaped!' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
IMPORTANT: Spaces need to be escaped!
Authored by: lionel77 on Dec 20, '05 08:20:37PM
Whenever you have spaces in path names you need to escape them if you work in the Terminal.

For example, the command cd ~/Pictures/Aperture Library.aplibrary listed in the hint is interpreted by the shell as cd ~/Pictures/Aperture.
So you want to use cd ~/Pictures/Aperture\ Library.aplibrary instead (note the backslash before the space).

It doen't matter much for the cd command as you will simply get an error message, but when you are creating symbolic links things can get a little messy if you don't properly escape the spaces in the path name.

PS:
Rob, I just noticed that the "To protect special characters such as..." message on the post a comment page is wrong. The code tags actually DON'T protect backslashes and the like. If you want a backslash in the text (regardless of within code tags or not) you need to actually type two backslashes. Another problem is that once you hit preview, one of the two backslashes is removed. I have a feeling that this behavior of the forum software is what is responsible for the absence of backslashes in the original hint.

[ Reply to This | # ]

IMPORTANT: Spaces need to be escaped!
Authored by: sjk on Dec 22, '05 08:13:08PM

Re: I have a feeling that this behavior of the forum software is what is responsible for the absence of backslashes in the original hint.

And in your followup example, too. :-)

I recently posted (again) about that backslash issue after it bit me (again) but didn't get an acknowledgment from Rob (again). :-(

Anyway, I usually recommend putting single-quotes around pathnames that contain spaces instead of using backslashes, like:

cd '~/Pictures/Aperture Library.aplibrary'

... with your example.



[ Reply to This | # ]
IMPORTANT: Spaces need to be escaped!
Authored by: lionel77 on Dec 24, '05 04:08:04AM
Very weird, I could have sworn the backslash was in my post after I had posted it...
Yes, single quotes would also work. I usually avoid them as I think that they tend to make thinks more messy but that might be a subjective thing.

Just out of curiosity, a quick test:
one bs: /
two bs: //
three bs: ///
four bs: ////


[ Reply to This | # ]

Forum software is fixed now
Authored by: lionel77 on Dec 24, '05 04:11:22AM

Looks like the backslash eating behavior of the forum software has been fixed now. Excellent. :)



[ Reply to This | # ]
Forum software is NOT fixed
Authored by: lionel77 on Dec 24, '05 04:19:28AM

Looks like I need some sleep, I confused slashes with backslashes in my earlier test.



[ Reply to This | # ]
backslashes vs. quotes
Authored by: sjk on Dec 30, '05 11:43:22AM
Yes, single quotes would also work. I usually avoid them as I think that they tend to make thinks more messy but that might be a subjective thing.

Yep, personal preference is subjective; backslash-quoted text looks sloppier to me. I'll sometimes use them in interactive shells but avoid unnecessary usage in scripts. And I think experienced shell programmers (those I respect most anyway :-)) recommend using single- or double-quoted strings. Anyway, viewing filenames that contain backslash-quoting is more inefficiently unreadable to me than simply dropping any quotes from each end.

[ Reply to This | # ]