Project

General

Profile

Backport #7143

system("ls && ls") should work in windows

Added by rogerdpack (Roger Pack) about 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:47912]

Description

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-


Related issues

Related to Ruby master - Feature #4269: command with && should execute as shellClosed01/12/2011Actions

Associated revisions

Revision acd82f6e
Added by usa (Usaku NAKAMURA) about 7 years ago

  • win32/win32.c (has_redirection): should use shell (cmd.exe) when the commandline containts '&'. reported by Roger Pack at [ruby-core:47912] [Bug #7143], and patched by Heesob Park at [ruby-core:47931].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37322
Added by usa (Usaku NAKAMURA) about 7 years ago

  • win32/win32.c (has_redirection): should use shell (cmd.exe) when the commandline containts '&'. reported by Roger Pack at [ruby-core:47912] [Bug #7143], and patched by Heesob Park at [ruby-core:47931].

Revision 37322
Added by usa (Usaku NAKAMURA) about 7 years ago

  • win32/win32.c (has_redirection): should use shell (cmd.exe) when the commandline containts '&'. reported by Roger Pack at [ruby-core:47912] [Bug #7143], and patched by Heesob Park at [ruby-core:47931].

Revision 37322
Added by usa (Usaku NAKAMURA) about 7 years ago

  • win32/win32.c (has_redirection): should use shell (cmd.exe) when the commandline containts '&'. reported by Roger Pack at [ruby-core:47912] [Bug #7143], and patched by Heesob Park at [ruby-core:47931].

Revision 37322
Added by usa (Usaku NAKAMURA) about 7 years ago

  • win32/win32.c (has_redirection): should use shell (cmd.exe) when the commandline containts '&'. reported by Roger Pack at [ruby-core:47912] [Bug #7143], and patched by Heesob Park at [ruby-core:47931].

Revision 37322
Added by usa (Usaku NAKAMURA) about 7 years ago

  • win32/win32.c (has_redirection): should use shell (cmd.exe) when the commandline containts '&'. reported by Roger Pack at [ruby-core:47912] [Bug #7143], and patched by Heesob Park at [ruby-core:47931].

Revision 37322
Added by usa (Usaku NAKAMURA) about 7 years ago

  • win32/win32.c (has_redirection): should use shell (cmd.exe) when the commandline containts '&'. reported by Roger Pack at [ruby-core:47912] [Bug #7143], and patched by Heesob Park at [ruby-core:47931].

Revision c58402cd
Added by usa (Usaku NAKAMURA) about 7 years ago

merge revision(s) 37322: [Backport #7143]

    * win32/win32.c (has_redirection): should use shell (cmd.exe) when
      the commandline containts '&'.
      reported by Roger Pack at [ruby-core:47912] [Bug #7143], and
      patched by Heesob Park at [ruby-core:47931].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37549
Added by usa (Usaku NAKAMURA) about 7 years ago

merge revision(s) 37322: [Backport #7143]

* win32/win32.c (has_redirection): should use shell (cmd.exe) when
  the commandline containts '&'.
  reported by Roger Pack at [ruby-core:47912] [Bug #7143], and
  patched by Heesob Park at [ruby-core:47931].

History

Updated by phasis68 (Heesob Park) about 7 years ago

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;

Updated by luislavena (Luis Lavena) about 7 years ago

  • 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?

#3

Updated by usa (Usaku NAKAMURA) about 7 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37322.
Roger, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • win32/win32.c (has_redirection): should use shell (cmd.exe) when the commandline containts '&'. reported by Roger Pack at [ruby-core:47912] [Bug #7143], and patched by Heesob Park at [ruby-core:47931].
#4

Updated by usa (Usaku NAKAMURA) about 7 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193
  • Category deleted (misc)
  • Status changed from Closed to Assigned
#5

Updated by usa (Usaku NAKAMURA) about 7 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r37549.
Roger, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 37322: [Backport #7143]

* win32/win32.c (has_redirection): should use shell (cmd.exe) when
  the commandline containts '&'.
  reported by Roger Pack at [ruby-core:47912] [Bug #7143], and
  patched by Heesob Park at [ruby-core:47931].

Also available in: Atom PDF