diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-08-27 01:14:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-08-27 01:14:30 +0000 |
commit | e8d486e119ac254cf2438d2b5bd9de2ec5af8ebc (patch) | |
tree | 4de32880216a4fc4fe244bd4093eed2ec2b497f1 /process.c | |
parent | 9b6bafef387de68aa9a31f39470e660b6524443d (diff) | |
download | ruby-e8d486e119ac254cf2438d2b5bd9de2ec5af8ebc.tar.gz |
* process.c (rb_proc_exec): strip trailing spaces. [ruby-dev:24143]
* win32/win32.c (CreateChild): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1027,8 +1027,17 @@ rb_proc_exec(str) after_exec(); #else for (s=str; *s; s++) { + if (ISSPACE(*s)) { + const char *p, *nl = NULL; + for (p = s; ISSPACE(*p); p++) { + if (*p == '\n') nl = p; + } + if (!*p) break; + if (nl) goto via_shell; + } if (*s != ' ' && !ISALPHA(*s) && strchr("*?{}[]<>()~&|\\$;'`\"\n",*s)) { int status; + via_shell: #if defined(MSDOS) before_exec(); status = system(str); @@ -1056,7 +1065,8 @@ rb_proc_exec(str) } a = argv = ALLOCA_N(char*, (s-str)/2+2); ss = ALLOCA_N(char, s-str+1); - strcpy(ss, str); + memcpy(ss, str, s-str); + ss[s-str] = '\0'; if (*a++ = strtok(ss, " \t")) { while (t = strtok(NULL, " \t")) { *a++ = t; |