Forum: Ruby-core [ruby-trunk - Bug #7143][Open] system("ls && ls") should work in windows

Posted by Roger Pack (rogerdpack)
on 2012-10-11 20:10
(Received via mailing list)
Issue #7143 has been reported by rogerdpack (Roger Pack).

----------------------------------------
Bug #7143: system("ls && ls") should work in windows
https://bugs.ruby-lang.org/issues/7143

Author: rogerdpack (Roger Pack)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]


Hello.
Since windows "on the command line" supports &&, I believe this should 
work for ruby system commands.

It appears this run both commands, as expected (the first one fails):

using "||" works well:

>> system("ffmpeg -i || ls") # ffmpeg -i fails

using &&

>> system("ls && ls")
ls: &&: No such file or directory
ls: ls: No such file or directory
=> false

Thanks.
-roger-
Posted by Heesob Park (phasis)
on 2012-10-12 07:19
(Received via mailing list)
Issue #7143 has been updated by phasis68 (Heesob Park).


As you know, && is a shell feature.

using "&&" works well when used with the internal command.

irb(main):001:0> system('ver && ls')

Microsoft Windows XP [Version 5.1.2600]
Thumbs.db       devkitvars.ps1  home     m.ico     msys.ico     qq2 
xxx
bin             dk.rb           include  mingw     postinstall  sbin
devkitvars.bat  etc             lib      msys.bat  qq           share
=> true

Here is a simple patch to invoke shell when command contains '&':
diff --git a/win32.c b/win32.c.new
index 7eaf1fc..3446728 100644
--- a/win32.c
+++ b/win32.c.new
@@ -1446,6 +1446,7 @@ has_redirection(const char *cmd)
          case '>':
          case '<':
          case '|':
+         case '&':
          case '\n':
            if (!quote)
                return TRUE;


----------------------------------------
Bug #7143: system("ls && ls") should work in windows
https://bugs.ruby-lang.org/issues/7143#change-30375

Author: rogerdpack (Roger Pack)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]


Hello.
Since windows "on the command line" supports &&, I believe this should 
work for ruby system commands.

It appears this run both commands, as expected (the first one fails):

using "||" works well:

>> system("ffmpeg -i || ls") # ffmpeg -i fails

using &&

>> system("ls && ls")
ls: &&: No such file or directory
ls: ls: No such file or directory
=> false

Thanks.
-roger-
Posted by Luis Lavena (luislavena)
on 2012-10-21 07:12
(Received via mailing list)
Issue #7143 has been updated by luislavena (Luis Lavena).

Category set to misc
Status changed from Open to Assigned
Assignee set to usa (Usaku NAKAMURA)

Usa, do you think adding such support is a good thing?
----------------------------------------
Bug #7143: system("ls && ls") should work in windows
https://bugs.ruby-lang.org/issues/7143#change-31119

Author: rogerdpack (Roger Pack)
Status: Assigned
Priority: Normal
Assignee: usa (Usaku NAKAMURA)
Category: misc
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]


Hello.
Since windows "on the command line" supports &&, I believe this should 
work for ruby system commands.

It appears this run both commands, as expected (the first one fails):

using "||" works well:

>> system("ffmpeg -i || ls") # ffmpeg -i fails

using &&

>> system("ls && ls")
ls: &&: No such file or directory
ls: ls: No such file or directory
=> false

Thanks.
-roger-
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.