ruby-changes:18955
From: kosaki <ko1@a...>
Date: Mon, 28 Feb 2011 22:54:46 +0900 (JST)
Subject: [ruby-changes:18955] Ruby:r30987 (trunk): * win32/win32.c (rb_w32_spawn): use shell if a commandline contain
kosaki 2011-02-28 22:52:58 +0900 (Mon, 28 Feb 2011) New Revision: 30987 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30987 Log: * 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. Modified files: trunk/ChangeLog trunk/test/ruby/test_system.rb trunk/win32/win32.c Index: ChangeLog =================================================================== --- ChangeLog (revision 30986) +++ ChangeLog (revision 30987) @@ -1,3 +1,15 @@ +Mon Feb 28 22:48:56 2011 KOSAKI Motohiro <kosaki.motohiro@g...> + + * 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@f...> * ext/openssl/ossl_pkcs7.c: parenthesize macro arguments. Index: win32/win32.c =================================================================== --- win32/win32.c (revision 30986) +++ win32/win32.c (revision 30987) @@ -851,6 +851,9 @@ { char cmdname[9], *b = cmdname, c; + if (strchr(cmd, '^')) + return 1; + do { if (!(c = *cmd++)) return 0; } while (isspace(c)); @@ -1139,6 +1142,12 @@ 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))) { Index: test/ruby/test_system.rb =================================================================== --- test/ruby/test_system.rb (revision 30986) +++ test/ruby/test_system.rb (revision 30987) @@ -102,11 +102,10 @@ 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 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/