Windows filenames and "/" (was Re: logtext and logfile)

Bill Campbell bill at celestial.com
Mon Mar 3 12:58:16 PST 2008


On Mon, Mar 03, 2008, Fairlight wrote:
>Is it just me, or did Kenneth Brody say:
>> No, filePro doesn't care.  Perhaps a better wording would have been "unless
>> you're passing the filename to SYSTEM, and running a command which does
>> care about them, there is no need to flip the slashes under Windows".  The
>> point is, once you're passing the filename to something outside of filePro,
>> you have to know the "other side" in order to get a definitive answer to
>> the question.  Everything (well, probably everything) will accept paths
>> with backslashes from the command line.
>
>Makes sense on all points.
>
>> How does Perl's system() handle things like "dir \path\to\directory /w"?
>
>Depends how you quote it to system().  If you use interpolating quotes,
>then something like "dir \temp /w" results in a directory not found.  If
>you use non-interpolating quotes, it's fine because it hasn't changed it to
>a tab (in this example) rather than a literal \t.  This only holds (I
>believe) if you are doing this on the command line with a literal string
>inside interpolating quotes.  If you have a variable that gets its contents
>elsewhere and feed -that- to system(), it won't double-interpolate the
>variable.  So if you had:
>
>$cmd = 'dir \temp /w';
>system("$cmd extra_args");
>
>...That would work.  Now if you used interpolating quotes (ie.,
>doublequotes, or qq()) when assigning $cmd in the first place, all bets are
>off again because you're telling it to interpolate backslashes before it
>even hits system().

Python makes this simple by prefixing quotes with ``r''.  That is
these should be equivalent in python

cmd = r'something \appl\fp\termcap'
cmd = r"something \appl\fp\termcap"
cmd = r'''something \appl\fp\termcap'''
cmd = 'something \\appl\\fp\\termcap'

>It's really not a matter of system() itself, but rather how and if you
>interpolate, and where.  You just have to remember that perl won't double
>interpolate, but it will single interpolate. :) (I've tried, with no
>success, to get things I -needed- double interpolated to do so, to no
>measure of success.)

Python never interpolates, so one has to use its ``%'' syntax
which is similar to printf.

>And damn CP/M for starting the whole slash war to begin with.  It -was-
>originated there, right?

Exactly.  CP/M used forward slashes as command options, and the
first version of MS-DOS, purchased by Microsoft from Seattle
Computer, was basically a port of CP/M to the 80x86 chipset, flat
file system and all.  About the only thing they did was replace
the PIP program with COPY putting the arguments in the correct
order (e.d. ``PIP DEST SOURCE'' became ``COPY SOURCE DEST'').

Bill
--
INTERNET:   bill at celestial.com  Bill Campbell; Celestial Software LLC
URL: http://www.celestial.com/  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676

"There strongest reason for the people to retain the right to keep and
 bear arms is, as a last resort, to protect themselves against tyranny
 in government." --1 Thomas Jefferson Papers, 334 (C.J.Boyd, Ed.,1950)


More information about the Filepro-list mailing list