summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkeiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-21 12:21:11 +0000
committerkeiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-03-21 12:21:11 +0000
commit06d1cbb92691638db23984b32a8011c6dd602fdb (patch)
tree0b33fb720ebfa2967055af4abb5f3bd6c23dd517
parentb9c8bcafdce125d9e1dea00f77bc9e15e9510d8b (diff)
* 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
-rw-r--r--ChangeLog4
-rw-r--r--lib/shell/command-processor.rb16
-rw-r--r--lib/shell/filter.rb7
-rw-r--r--lib/shell/system-command.rb2
4 files changed, 20 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 1f846a8498..0d8b18376a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* ruby.1: add -width option to .Bl for old groff.
diff --git a/lib/shell/command-processor.rb b/lib/shell/command-processor.rb
index ce5102a9c4..6f8e5ffd09 100644
--- a/lib/shell/command-processor.rb
+++ b/lib/shell/command-processor.rb
@@ -21,6 +21,7 @@ require "shell/builtin-command"
class Shell
class CommandProcessor
+# include Error
#
# initialize of Shell and related classes.
@@ -220,6 +221,13 @@ class Shell
# sh.system("ls", "-l") | sh.head > STDOUT
#
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)
end
@@ -277,7 +285,7 @@ class Shell
when IO
AppendIO.new(@shell, to, filter)
else
- Shell.Fail CantApplyMethod, "append", to.class
+ Shell.Fail Error::CantApplyMethod, "append", to.class
end
end
@@ -327,10 +335,10 @@ class Shell
if exists?(path)
return path
else
- Shell.Fail CommandNotFound, command
+ Shell.Fail Error::CommandNotFound, command
end
when false
- Shell.Fail CommandNotFound, command
+ Shell.Fail Error::CommandNotFound, command
end
for p in @shell.system_path
@@ -341,7 +349,7 @@ class Shell
end
end
@system_commands[command] = false
- Shell.Fail CommandNotFound, command
+ Shell.Fail Error::CommandNotFound, command
end
#
diff --git a/lib/shell/filter.rb b/lib/shell/filter.rb
index 4cf793a3b3..27c5534695 100644
--- a/lib/shell/filter.rb
+++ b/lib/shell/filter.rb
@@ -18,7 +18,6 @@ class Shell
#
class Filter
include Enumerable
- include Error
def initialize(sh)
@shell = sh # parent shell
@@ -47,7 +46,7 @@ class Shell
self.input = src
self
else
- Filter.Fail CantApplyMethod, "<", to.class
+ Shell.Fail Error::CantApplyMethod, "<", to.class
end
end
@@ -63,7 +62,7 @@ class Shell
when IO
each(){|l| to << l}
else
- Filter.Fail CantApplyMethod, ">", to.class
+ Shell.Fail Error::CantApplyMethod, ">", to.class
end
self
end
@@ -72,7 +71,7 @@ class Shell
begin
Shell.cd(@shell.pwd).append(to, self)
rescue CantApplyMethod
- Shell.Fail CantApplyMethod, ">>", to.class
+ Shell.Fail Error::CantApplyMethod, ">>", to.class
end
end
diff --git a/lib/shell/system-command.rb b/lib/shell/system-command.rb
index 6071c1c841..f87ba890ea 100644
--- a/lib/shell/system-command.rb
+++ b/lib/shell/system-command.rb
@@ -16,7 +16,7 @@ class Shell
class SystemCommand < Filter
def initialize(sh, command, *opts)
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
super(sh)
@command = command