From 4c23eddb18a8a8ff105ae875eba16c26f11fe073 Mon Sep 17 00:00:00 2001 From: Laurent Julliard Date: Fri, 18 Jul 2008 00:28:15 +0200 Subject: [PATCH] Couple of changes in preparation of the upcoming ARGF class * Modify a couple of default values for predefined global variables and add $-i for in place edit mode * fix a bug: the value returned by the setter of a hooked global variable must be stored in the internal array --- kernel/core/global.rb | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-) diff --git a/kernel/core/global.rb b/kernel/core/global.rb index 476970c..4b287ec 100644 --- a/kernel/core/global.rb +++ b/kernel/core/global.rb @@ -24,11 +24,13 @@ class GlobalVariables :$CONSOLE => STDOUT, :$DEBUG => false, :$SAFE => 0, - :$. => 0, # TODO: Last line number of IO read. - :$_ => nil, # HACK: bunk for now. - :$< => nil, # HACK: should be ARGF - :$? => nil, # Process status. nil until set - :$= => false # ignore case, whatever that is + :$FILENAME => '-', # current IO file + :$. => 0, # TODO: Last line number of IO read. + :$_ => nil, # HACK: bunk for now. + :$< => nil, # ARGF (set it in argf.rb + :$? => nil, # Process status. nil until set + :$= => false, # ignore case, whatever that is + :$-i => nil # in place edit mode is disabled by default ) @alias = LookupTable.new @@ -57,7 +59,7 @@ class GlobalVariables if !@internal.key?(key) && alias_key = @alias[key] then @internal[alias_key] = data elsif @hooks.key? key then - @hooks[key][1].arity == 1 ? @hooks[key][1].call(data) : @hooks[key][1].call(data, key) + @internal[key] = (@hooks[key][1].arity == 1 ? @hooks[key][1].call(data) : @hooks[key][1].call(data, key)) else @internal[key] = data end -- 1.5.4.5