Permalink
Browse files

Move Rubinius::Terminal constant to kernel, wire up IO#tty? to suppor…

…t it.

Environment::set_rubinius_constants() is now gone, as it is not needed.
  • Loading branch information...
1 parent d58394d commit c11533d567062775d1d9177e99309e874a529bd3 @drbrain drbrain committed Aug 28, 2008
View
@@ -1339,16 +1339,14 @@ def to_io
self
end
- alias_method :prim_tty?, :tty?
-
##
# Returns true if ios is associated with a terminal device (tty), false otherwise.
#
# File.new("testfile").isatty #=> false
# File.new("/dev/tty").isatty #=> true
def tty?
raise IOError, "closed stream" if closed?
- prim_tty?
+ Platform::POSIX.isatty(@descriptor) == 1
end
alias_method :isatty, :tty?
View
@@ -7,3 +7,10 @@ class IO::BidirectionalPipe
undef_method method
end
end
+
+# Re-setup all the stdio channels, to pull in new ivars
+
+STDOUT.setup
+STDIN.setup
+STDERR.setup
+
@@ -0,0 +1,6 @@
+# depends on: io.rb
+
+module Rubinius
+ Terminal = STDIN.tty?
+end
+
View
@@ -1,11 +1,5 @@
# Contained first is the system startup code.
-# Re-setup all the stdio channels, to pull in new ivars
-
-STDOUT.setup
-STDIN.setup
-STDERR.setup
-
begin
ENV = EnvironmentVariables.new
@@ -110,7 +104,7 @@
puts RBS_USAGE
exit 1
when "-v"
- puts "rubinius #{RBX_VERSION} (ruby #{RUBY_VERSION} compatible) (#{Rubinius::BUILDREV[0..8]}) (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
+ puts "rubinius #{Rubinius::RBX_VERSION} (ruby #{RUBY_VERSION} compatible) (#{Rubinius::BUILDREV[0..8]}) (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
$VERBOSE = true
exit 0 if ARGV.empty?
when "-w"
@@ -70,7 +70,8 @@ module Platform::POSIX
attach_function 'clearerr', [:pointer], :void
attach_function 'fseek', [:pointer, :int, :int], :int
attach_function 'ftell', [:pointer], :int
- attach_function 'lseek', [:int, :int, :int], :int
+ attach_function 'lseek', [:int, :int, :int], :int
+ attach_function 'isatty', [:int], :int
# reading
attach_function 'fread', [:string, :size_t, :size_t, :pointer], :size_t
@@ -6,11 +6,12 @@ file 'lib/rbconfig.rb' do
write_rbconfig
end
-file 'kernel/bootstrap/rubinius_config.rb' => 'rakelib/configuration.rb' do |task, args|
+file 'kernel/bootstrap/rubinius_config.rb' =>
+ %w[rakelib/configuration.rb rakelib/configure.rake] do |task, args|
open task.name, 'w' do |io|
io << <<-EOF
#--
-# This file was generated from rakelib/configur.rake
+# This file was generated from rakelib/configure.rake
#++
module Rubinius
@@ -20,15 +21,17 @@ module Rubinius
RBA_PATH = #{RBX_RBA_PATH.inspect}
RBX_VERSION = #{RBX_VERSION.inspect}
end
+
EOF
end
end
-file 'kernel/bootstrap/ruby_config.rb' => 'rakelib/configuration.rb' do |task, args|
+file 'kernel/bootstrap/ruby_config.rb' =>
+ %w[rakelib/configuration.rb rakelib/configure.rake] do |task, args|
open task.name, 'w' do |io|
io << <<-EOF
#--
-# This file was generated from rakelib/configur.rake
+# This file was generated from rakelib/configure.rake
#++
PLATFORM = #{RBX_HOST.inspect}
View
@@ -45,7 +45,6 @@ int main(int argc, char** argv) {
}
std::string root = std::string(e);
- env.set_rubinius_constants();
std::cout << "Loading platform.conf: " << root << "\n";
env.load_platform_conf(root);
View
@@ -97,16 +97,4 @@ namespace rubinius {
}
}
- /*
- * HACK hook this up to a config file
- */
- void Environment::set_rubinius_constants() {
- Module* rubinius = GO(rubinius).get();
-
- if(isatty(fileno(stdin))) {
- rubinius->set_const(state, "Terminal", Qtrue);
- } else {
- rubinius->set_const(state, "Terminal", Qfalse);
- }
- }
}
View
@@ -19,8 +19,8 @@ namespace rubinius {
void load_directory(std::string dir);
void load_platform_conf(std::string dir);
void run_file(std::string path);
- void set_rubinius_constants();
};
+
}
#endif

0 comments on commit c11533d

Please sign in to comment.