ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:22960] [Bug #1304] Kernel#system bug
@ 2009-03-19 17:42 Borislav Stanimirov
  2009-03-20  2:30 ` [ruby-core:22965] " Nobuyoshi Nakada
  0 siblings, 1 reply; 6+ messages in thread
From: Borislav Stanimirov @ 2009-03-19 17:42 UTC (permalink / raw
  To: ruby-core

Bug #1304: Kernel#system bug
http://redmine.ruby-lang.org/issues/show/1304

Author: Borislav Stanimirov
Status: Open, Priority: Normal
Category: lib
ruby -v: 1.9.1p0

To reproduce on Windows:
Create a batch file with one argument in a folder that has a space in its name. In Ruby call: 
        system('"c:\\your full path\\batchfile.bat" yourparam')

It will behave as if the quotations are missing. (Error: c:\your is not recognized as a command...)


----------------------------------------
http://redmine.ruby-lang.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:22965] Re: [Bug #1304] Kernel#system bug
  2009-03-19 17:42 [ruby-core:22960] [Bug #1304] Kernel#system bug Borislav Stanimirov
@ 2009-03-20  2:30 ` Nobuyoshi Nakada
  2009-03-20  2:55   ` [ruby-core:22966] " Dave B
                     ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Nobuyoshi Nakada @ 2009-03-20  2:30 UTC (permalink / raw
  To: ruby-core

Hi,

At Fri, 20 Mar 2009 02:42:11 +0900,
Borislav Stanimirov wrote in [ruby-core:22960]:
> To reproduce on Windows:
> Create a batch file with one argument in a folder that has a space in its name. In Ruby call: 
>         system('"c:\\your full path\\batchfile.bat" yourparam')
> 
> It will behave as if the quotations are missing. (Error: c:\your is not recognized as a command...)

It can't reproduce.

$ cat "tmp/foo bar/test.bat"
echo %0 %*

$ ./i386-mswin32/ruby -v -e 'bat=File.expand_path(ARGV[0]).tr("/", "\\"); p system(%["#{bat}" 1 2 3])' "tmp/foo bar/test.bat"
ruby 1.9.1p0 (2009-03-04 revision 22762) [i386-mswin32]
c:\Users\nobu\src\ruby\ruby-1.9.1>echo "c:\Users\nobu\src\ruby\ruby-1.9.1\tmp\foo bar\test.bat" 1 2 3
"c:\Users\nobu\src\ruby\ruby-1.9.1\tmp\foo bar\test.bat" 1 2 3
true

-- 
Nobu Nakada

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:22966] [Bug #1304] Kernel#system bug
  2009-03-20  2:30 ` [ruby-core:22965] " Nobuyoshi Nakada
@ 2009-03-20  2:55   ` Dave B
  2009-03-20  7:13   ` [ruby-core:22970] " Borislav Stanimirov
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Dave B @ 2009-03-20  2:55 UTC (permalink / raw
  To: ruby-core

Issue #1304 has been updated by Dave B.



puts RUBY_DESCRIPTION
#=> ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32_90]

system('"C:\\Documents and Settings\\batchfile.bat" myparam')

(No problem)


daz

----------------------------------------
http://redmine.ruby-lang.org/issues/show/1304

----------------------------------------
http://redmine.ruby-lang.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:22970] [Bug #1304] Kernel#system bug
  2009-03-20  2:30 ` [ruby-core:22965] " Nobuyoshi Nakada
  2009-03-20  2:55   ` [ruby-core:22966] " Dave B
@ 2009-03-20  7:13   ` Borislav Stanimirov
  2009-03-20 10:12   ` [ruby-core:22972] " Heesob Park
  2009-03-20 23:24   ` [ruby-core:22980] [Bug #1304](Closed) " Nobuyoshi Nakada
  3 siblings, 0 replies; 6+ messages in thread
From: Borislav Stanimirov @ 2009-03-20  7:13 UTC (permalink / raw
  To: ruby-core

Issue #1304 has been updated by Borislav Stanimirov.


I am sorry that I mislead you. It turns out that the parameter needs to be in quoutations too (as if it's another file with a space in it)

my exact test case:

BackwardCopy.cmd:
@copy %2 %1

Test.rb:
system('"C:\\New Folder\\BackwardCopy.cmd" "C:\\New Folder\\target.txt" "C:\\New Folder\\source.txt"')

So I tested it some more and if the arguments have no quoutations it works ok. Here is an even simpler case that reproduces the bug:

Test.cmd:
echo %1 %2

Test.rb:
system('"C:/New Folder/test.cmd" "a" b') #=>'C:/New' is not recognized as an internal or external command,
operable program or batch file.
#system('"C:/New Folder/test.cmd" a b') works



----------------------------------------
http://redmine.ruby-lang.org/issues/show/1304

----------------------------------------
http://redmine.ruby-lang.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:22972] [Bug #1304] Kernel#system bug
  2009-03-20  2:30 ` [ruby-core:22965] " Nobuyoshi Nakada
  2009-03-20  2:55   ` [ruby-core:22966] " Dave B
  2009-03-20  7:13   ` [ruby-core:22970] " Borislav Stanimirov
@ 2009-03-20 10:12   ` Heesob Park
  2009-03-20 23:24   ` [ruby-core:22980] [Bug #1304](Closed) " Nobuyoshi Nakada
  3 siblings, 0 replies; 6+ messages in thread
From: Heesob Park @ 2009-03-20 10:12 UTC (permalink / raw
  To: ruby-core

Issue #1304 has been updated by Heesob Park.


According to the document of CreateProcess (http://msdn.microsoft.com/en-us/library/ms682425.aspx) :
To run a batch file, you must start the command interpreter; set lpApplicationName to cmd.exe and set lpCommandLine to the following arguments: /c plus the name of the batch file.

Here is a quick patch:
--- win32.c     2009-01-16 00:37:20.000000000 +0900
+++ win32.c.new 2009-03-20 19:08:24.000000000 +0900
@@ -1002,6 +1002,10 @@
       command_found:
        shell = p;
        translate_char(p, '/', '\\');
+    if(stricmp(shell+strlen(shell)-4,".bat")==0 ||
+         stricmp(shell+strlen(shell)-4,".cmd")==0)  {
+         shell = NULL;
+       }
     }

     return child_result(CreateChild(cmd, shell, NULL, NULL, NULL, NULL), mode);


----------------------------------------
http://redmine.ruby-lang.org/issues/show/1304

----------------------------------------
http://redmine.ruby-lang.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [ruby-core:22980] [Bug #1304](Closed) Kernel#system bug
  2009-03-20  2:30 ` [ruby-core:22965] " Nobuyoshi Nakada
                     ` (2 preceding siblings ...)
  2009-03-20 10:12   ` [ruby-core:22972] " Heesob Park
@ 2009-03-20 23:24   ` Nobuyoshi Nakada
  3 siblings, 0 replies; 6+ messages in thread
From: Nobuyoshi Nakada @ 2009-03-20 23:24 UTC (permalink / raw
  To: ruby-core

Issue #1304 has been updated by Nobuyoshi Nakada.

Status changed from Feedback to Closed
% Done changed from 0 to 100

Applied in changeset r23023.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/1304

----------------------------------------
http://redmine.ruby-lang.org

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-03-20 23:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-19 17:42 [ruby-core:22960] [Bug #1304] Kernel#system bug Borislav Stanimirov
2009-03-20  2:30 ` [ruby-core:22965] " Nobuyoshi Nakada
2009-03-20  2:55   ` [ruby-core:22966] " Dave B
2009-03-20  7:13   ` [ruby-core:22970] " Borislav Stanimirov
2009-03-20 10:12   ` [ruby-core:22972] " Heesob Park
2009-03-20 23:24   ` [ruby-core:22980] [Bug #1304](Closed) " Nobuyoshi Nakada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).