[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] csc.scm.in unescaped whitespace in pathnames
From: |
John Cowan |
Subject: |
Re: [Chicken-users] csc.scm.in unescaped whitespace in pathnames |
Date: |
Sat, 22 Jul 2006 13:42:06 -0400 |
User-agent: |
Mutt/1.3.28i |
Brandon J. Van Every scripsit:
> So now the question is how the shell should be invoked in csc.scm.in
> with respect to unescaped whitespace.
Okay, let me try to straighten out the issue here. What we have is
a program (in C or Scheme, it doesn't matter) trying to pass a string
to the shell that may contain whitespace, but that the shell is supposed
to see as a single string.
There are therefore two requirements:
1) The C or Scheme program must recognize the string as a string. That
means it must be enclosed in double quotes, and any double quotes or
backslashes in the string must be escaped.
2) What the shell receives from the program must itself have either:
a) double quotes around it, or
b) all spaces escaped by backslashes.
Furthermore, any backslashes (or double-quotes) must be escaped.
So. If what we want the shell to pass on is the single string
C:\Program Files\chicken
then it must receive either
"C:\\Program Files\\chicken"
or else
C:\\Program\ Files\\chicken
And that means the C or Scheme program must contain one of these strings:
"\"C:\\\\Program Files\\\\chicken\""
or
"C:\\\\Program\\ Files\\\\chicken"
Look over these examples carefully, and when you understand what
every backslash is doing there, then you'll Get It. Yes, it's awful.
Unfortunately, that's the way things are.
Because it's so painful to get this right, lots of Unix programs do
punt on pathnames containing spaces (which, I repeat, are just as
legal on Unix as they are on Windows, though far less common).
--
He played King Lear as though John Cowan <address@hidden>
someone had played the ace. http://www.ccil.org/~cowan
--Eugene Field