summaryrefslogtreecommitdiffstats
path: root/lib/shell/builtin-command.rb
diff options
context:
space:
mode:
authorkeiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-20 12:38:58 +0000
committerkeiju <keiju@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-03-20 12:38:58 +0000
commit244f4e1a9e0974e48fe8477b8c133a392dbae737 (patch)
tree3f6024dcb1fe3a3ca6b3fd613f436fd99c80c80c /lib/shell/builtin-command.rb
parentbd620be622c60c4857be88d3a40f77fe28328d91 (diff)
downloadruby-244f4e1a9e0974e48fe8477b8c133a392dbae737.tar.gz
ruby-244f4e1a9e0974e48fe8477b8c133a392dbae737.tar.xz
ruby-244f4e1a9e0974e48fe8477b8c133a392dbae737.zip
* lib/shell.rb, lib/shell: support for ruby 1.9(YARV) thread model.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@12110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/shell/builtin-command.rb')
-rw-r--r--lib/shell/builtin-command.rb31
1 files changed, 19 insertions, 12 deletions
diff --git a/lib/shell/builtin-command.rb b/lib/shell/builtin-command.rb
index db1adfa48..cfdbc046a 100644
--- a/lib/shell/builtin-command.rb
+++ b/lib/shell/builtin-command.rb
@@ -1,9 +1,9 @@
#
# shell/builtin-command.rb -
-# $Release Version: 0.6.0 $
+# $Release Version: 0.7 $
# $Revision$
# $Date$
-# by Keiju ISHITSUKA(Nihon Rational Software Co.,Ltd)
+# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
# --
#
@@ -22,6 +22,16 @@ class Shell
end
end
+ class Void < BuiltInCommand
+ def initialize(sh, *opts)
+ super sh
+ end
+
+ def each(rs = nil)
+ # do nothing
+ end
+ end
+
class Echo < BuiltInCommand
def initialize(sh, *strings)
super sh
@@ -58,20 +68,17 @@ class Shell
super sh
@pattern = pattern
- Thread.critical = true
- back = Dir.pwd
- begin
- Dir.chdir @shell.cwd
- @files = Dir[pattern]
- ensure
- Dir.chdir back
- Thread.critical = false
- end
end
def each(rs = nil)
+ if @pattern[0] == ?/
+ @files = Dir[@pattern]
+ else
+ prefix = @shell.pwd+"/"
+ @files = Dir[prefix+@pattern].collect{|p| p.sub(prefix, "")}
+ end
rs = @shell.record_separator unless rs
- for f in @files
+ for f in @files
yield f+rs
end
end