mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/shell/*: bug fix for Shell#system(command_line_string).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b9c8bcafdc
commit
06d1cbb926
4 changed files with 20 additions and 9 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Mar 21 21:11:16 2004 Keiju Ishitsuka <keiju@ishitsuka.com>
|
||||||
|
|
||||||
|
* lib/shell/*: bug fix for Shell#system(command_line_string).
|
||||||
|
|
||||||
Sun Mar 21 21:04:42 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
Sun Mar 21 21:04:42 2004 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* ruby.1: add -width option to .Bl for old groff.
|
* ruby.1: add -width option to .Bl for old groff.
|
||||||
|
|
|
@ -21,6 +21,7 @@ require "shell/builtin-command"
|
||||||
|
|
||||||
class Shell
|
class Shell
|
||||||
class CommandProcessor
|
class CommandProcessor
|
||||||
|
# include Error
|
||||||
|
|
||||||
#
|
#
|
||||||
# initialize of Shell and related classes.
|
# initialize of Shell and related classes.
|
||||||
|
@ -220,6 +221,13 @@ class Shell
|
||||||
# sh.system("ls", "-l") | sh.head > STDOUT
|
# sh.system("ls", "-l") | sh.head > STDOUT
|
||||||
#
|
#
|
||||||
def system(command, *opts)
|
def system(command, *opts)
|
||||||
|
if opts.empty?
|
||||||
|
if command =~ /\*|\?|\{|\}|\[|\]|<|>|\(|\)|~|&|\||\\|\$|;|'|`|"|\n/
|
||||||
|
return SystemCommand.new(@shell, find_system_command("sh"), "-c", command)
|
||||||
|
else
|
||||||
|
command, *opts = command.split(/\s+/)
|
||||||
|
end
|
||||||
|
end
|
||||||
SystemCommand.new(@shell, find_system_command(command), *opts)
|
SystemCommand.new(@shell, find_system_command(command), *opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -277,7 +285,7 @@ class Shell
|
||||||
when IO
|
when IO
|
||||||
AppendIO.new(@shell, to, filter)
|
AppendIO.new(@shell, to, filter)
|
||||||
else
|
else
|
||||||
Shell.Fail CantApplyMethod, "append", to.class
|
Shell.Fail Error::CantApplyMethod, "append", to.class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -327,10 +335,10 @@ class Shell
|
||||||
if exists?(path)
|
if exists?(path)
|
||||||
return path
|
return path
|
||||||
else
|
else
|
||||||
Shell.Fail CommandNotFound, command
|
Shell.Fail Error::CommandNotFound, command
|
||||||
end
|
end
|
||||||
when false
|
when false
|
||||||
Shell.Fail CommandNotFound, command
|
Shell.Fail Error::CommandNotFound, command
|
||||||
end
|
end
|
||||||
|
|
||||||
for p in @shell.system_path
|
for p in @shell.system_path
|
||||||
|
@ -341,7 +349,7 @@ class Shell
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@system_commands[command] = false
|
@system_commands[command] = false
|
||||||
Shell.Fail CommandNotFound, command
|
Shell.Fail Error::CommandNotFound, command
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
|
@ -18,7 +18,6 @@ class Shell
|
||||||
#
|
#
|
||||||
class Filter
|
class Filter
|
||||||
include Enumerable
|
include Enumerable
|
||||||
include Error
|
|
||||||
|
|
||||||
def initialize(sh)
|
def initialize(sh)
|
||||||
@shell = sh # parent shell
|
@shell = sh # parent shell
|
||||||
|
@ -47,7 +46,7 @@ class Shell
|
||||||
self.input = src
|
self.input = src
|
||||||
self
|
self
|
||||||
else
|
else
|
||||||
Filter.Fail CantApplyMethod, "<", to.class
|
Shell.Fail Error::CantApplyMethod, "<", to.class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,7 +62,7 @@ class Shell
|
||||||
when IO
|
when IO
|
||||||
each(){|l| to << l}
|
each(){|l| to << l}
|
||||||
else
|
else
|
||||||
Filter.Fail CantApplyMethod, ">", to.class
|
Shell.Fail Error::CantApplyMethod, ">", to.class
|
||||||
end
|
end
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
@ -72,7 +71,7 @@ class Shell
|
||||||
begin
|
begin
|
||||||
Shell.cd(@shell.pwd).append(to, self)
|
Shell.cd(@shell.pwd).append(to, self)
|
||||||
rescue CantApplyMethod
|
rescue CantApplyMethod
|
||||||
Shell.Fail CantApplyMethod, ">>", to.class
|
Shell.Fail Error::CantApplyMethod, ">>", to.class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Shell
|
||||||
class SystemCommand < Filter
|
class SystemCommand < Filter
|
||||||
def initialize(sh, command, *opts)
|
def initialize(sh, command, *opts)
|
||||||
if t = opts.find{|opt| !opt.kind_of?(String) && opt.class}
|
if t = opts.find{|opt| !opt.kind_of?(String) && opt.class}
|
||||||
Shell.Fail TypeError, t.class, "String"
|
Shell.Fail Error::TypeError, t.class, "String"
|
||||||
end
|
end
|
||||||
super(sh)
|
super(sh)
|
||||||
@command = command
|
@command = command
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue