diff options
author | Christopher Faylor <me@cgf.cx> | 2000-11-20 22:10:13 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-11-20 22:10:13 +0000 |
commit | 9784d54da8326f03d7719fb6dc30fd158fc25083 (patch) | |
tree | 3d803bfbf108f3c2826b3d6acb54b9fa3642ef92 /winsup/cygwin | |
parent | 099efae038316c57af95c01abddaf246e3b6028d (diff) | |
download | cygnal-9784d54da8326f03d7719fb6dc30fd158fc25083.tar.gz cygnal-9784d54da8326f03d7719fb6dc30fd158fc25083.tar.bz2 cygnal-9784d54da8326f03d7719fb6dc30fd158fc25083.zip |
* spawn.cc (spawn_guts): Quoting was still wrong. Keep trying to fix it.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r-- | winsup/cygwin/ChangeLog | 5 | ||||
-rw-r--r-- | winsup/cygwin/spawn.cc | 26 |
2 files changed, 25 insertions, 6 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 929caf528..1151ba0c6 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +Mon Nov 20 17:04:43 2000 Christopher Faylor <cgf@cygnus.com> + + * spawn.cc (spawn_guts): Quoting was still wrong. Keep trying to + fix it. + Mon Nov 20 14:26:38 2000 Christopher Faylor <cgf@cygnus.com> * spawn.cc (spawn_guts): YA tweak for dealing with arcane rules of diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 211c15c04..030e6b6ab 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -480,17 +480,31 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv, else { one_line.add ("\"", 1); + /* Handle embedded special characters " and \. + A " is always preceded by a \. + A \ is not special unless it precedes a ". If it does, + then all preceding \'s must be doubled to avoid having + the Windows command line parser interpret the \ as quoting + the ". This rule applies to a string of \'s before the end + of the string, since cygwin/windows uses a " to delimit the + argument. */ for (; (p = strpbrk (a, "\"\\")); a = ++p) { one_line.add (a, p - a); - if (*p == '\\' && p[1] == '\\') + /* Find length of string of backslashes */ + int n = strspn (p, "\\"); + if (!n) + one_line.add ("\\\"", 2); /* No backslashes, so it must be a ". + The " has to be protected with a backslash. */ + else { - one_line.add ("\\\\\\", 3); - p++; + one_line.add (p, n); /* Add the run of backslashes */ + /* Need to double up all of the preceding + backslashes if they precede a quote or EOS. */ + if (!p[n] || p[n] == '"') + one_line.add (p, n); + p += n - 1; /* Point to last backslash */ } - else if ((*p == '\\' && p[1] == '"') || *p == '"') - one_line.add ("\\", 1); - one_line.add (p, 1); } if (*a) one_line.add (a); |