diff options
author | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-28 13:52:58 +0000 |
---|---|---|
committer | kosaki <kosaki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-28 13:52:58 +0000 |
commit | 4a57c5e7d961e457826ea5dabb758b249d8faeb0 (patch) | |
tree | 3bc772a5dfbcba0a2bfdd938fdc93416b2fe58ba | |
parent | 2755f11fd5a682cc5bf3c57f2e2af139d75c5be4 (diff) | |
download | ruby-4a57c5e7d961e457826ea5dabb758b249d8faeb0.tar.gz |
* win32/win32.c (rb_w32_spawn): use shell if a commandline contain
double-quote character.
* win32/win32.c (is_internal_cmd): similar, use shell if a commandline
contain caret character.
* test/ruby/test_system.rb (TestSystem#test_system_at): fix
wrong test case. if system() invoke a command by using shell,
system() never return nil. Also, "" quotation must not appear
twice in a command line.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | test/ruby/test_system.rb | 9 | ||||
-rw-r--r-- | win32/win32.c | 9 |
3 files changed, 25 insertions, 5 deletions
@@ -1,3 +1,15 @@ +Mon Feb 28 22:48:56 2011 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * win32/win32.c (rb_w32_spawn): use shell if a commandline contain + double-quote character. + * win32/win32.c (is_internal_cmd): similar, use shell if a commandline + contain caret character. + + * test/ruby/test_system.rb (TestSystem#test_system_at): fix + wrong test case. if system() invoke a command by using shell, + system() never return nil. Also, "" quotation must not appear + twice in a command line. + Mon Feb 28 17:36:57 2011 Tanaka Akira <akr@fsij.org> * ext/openssl/ossl_pkcs7.c: parenthesize macro arguments. diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index e54b0f4b43..34eb45f4c1 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -102,11 +102,10 @@ class TestSystem < Test::Unit::TestCase assert_equal("@@foo\n", `"echo" @@foo`, bug4396); assert_equal("@@foo\n", `"@@echo" @@foo`, bug4396); assert_equal("@@foo\n", `"@@echo @@foo"`, bug4396); - assert_equal('"@foo"\n', `"echo" "@foo"`, bug4396); # ^ + @ + built-in - assert_equal(nil, system('^@echo foo'), bug4396); - assert_equal(nil, system('"^@echo foo"'), bug4396); + assert_equal(false, system('^@echo foo'), bug4396); + assert_equal(false, system('"^@echo foo"'), bug4396); assert_equal("@foo\n", `echo ^@foo`); Dir.mktmpdir("ruby_script_tmp") {|tmpdir| @@ -120,8 +119,8 @@ class TestSystem < Test::Unit::TestCase assert_match(/\Abar\nbaz\n?\z/, `@@findstr "ba" #{tmpfilename.gsub("/", "\\")}`, bug4393); # "" + @ + non built-in - assert_match(/\Abar\nbaz\n?\z/, `"@@findstr" "ba" #{tmpfilename.gsub("/", "\\")}`, bug4396); - assert_match(/\A@foo\n?\z/, `"@@findstr" "@foo" #{tmpfilename.gsub("/", "\\")}`, bug4396); + assert_match(/\Abar\nbaz\n?\z/, `"@@findstr ba" #{tmpfilename.gsub("/", "\\")}`, bug4396); + assert_match(/\A@foo\n?\z/, `"@@findstr @foo" #{tmpfilename.gsub("/", "\\")}`, bug4396); } end end diff --git a/win32/win32.c b/win32/win32.c index 99802d07d0..1e658de156 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -851,6 +851,9 @@ is_internal_cmd(const char *cmd, int nt) { char cmdname[9], *b = cmdname, c; + if (strchr(cmd, '^')) + return 1; + do { if (!(c = *cmd++)) return 0; } while (isspace(c)); @@ -1139,6 +1142,12 @@ rb_w32_spawn(int mode, const char *cmd, const char *prog) cmd = tmp; } else if ((shell = getenv("COMSPEC")) && + strchr(cmd, '"')) { + char *tmp = ALLOCV(v, strlen(shell) + strlen(cmd) + sizeof(" /c ")); + sprintf(tmp, "%s /c %s", shell, cmd); + cmd = tmp; + } + else if ((shell = getenv("COMSPEC")) && (nt = !is_command_com(shell), (redir < 0 ? has_redirection(cmd) : redir) || is_internal_cmd(cmd, nt))) { |