On May 1, 2004, at 11:00 AM, Mark Wheeler wrote:

Then when I'm in the command line in the Terminal, to access the PRINCETON;DELLSERVER directory, I would use, for example:

% ls -l /Volumes/'PRINCETON;DELLSERVER'/

Yes. The single-quotes in the above will prevent the shell from parsing the ';' as the end of the command.


% ls -l /Volumes/PRINCETON\\;DELLSERVER/

Only a single back-slash is needed when you type it directly.

Two back-slashes are needed if you define it in a double-quoted string in a Perl script, but only one to define it in a single-quoted string, like so:

my $path = "/Volumes/FOO\\;BAR/";
system("ls -l $path");

$path = '/Volumes/FOO\;BAR/';
system("ls -l $path");

In double-quoted strings, Perl uses back-slashes for escape sequences too, like \t, \s, and \n. So, to include a literal back-slash, it has to be doubled. Single-quoted strings in Perl aren't processed for escape sequences, so doubling the back-slashes aren't needed. So both of the above Perl snippets will run the same command, passing a single back-slash to the shell:

ls -l /Volumes/FOO\;BAR/

% ls -l /Volumes/'PRINCETON\\;DELLSERVER'/

The shell follows the same quoting rules as Perl. So when you use single quotes here, the back-slashes aren't parsed as escapes - as a result, ls will look for a path that actually has two back slashes in it. Which is a legal file name here - this ain't MSDOS. ;-)


sherm--



Reply via email to