summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-27 01:14:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-27 01:14:30 +0000
commite8d486e119ac254cf2438d2b5bd9de2ec5af8ebc (patch)
tree4de32880216a4fc4fe244bd4093eed2ec2b497f1 /process.c
parent9b6bafef387de68aa9a31f39470e660b6524443d (diff)
* 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.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/process.c b/process.c
index 0132c31606..620513c8f8 100644
--- a/process.c
+++ b/process.c
@@ -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;