summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/irb/ext/history.rb4
-rw-r--r--lib/irb/extend-command.rb1
-rw-r--r--lib/irb/init.rb10
-rw-r--r--lib/irb/locale.rb14
-rw-r--r--lib/irb/slex.rb1
5 files changed, 13 insertions, 17 deletions
diff --git a/lib/irb/ext/history.rb b/lib/irb/ext/history.rb
index d40a62e959..55cd56de2f 100644
--- a/lib/irb/ext/history.rb
+++ b/lib/irb/ext/history.rb
@@ -22,7 +22,7 @@ module IRB
_set_last_value(value)
@workspace.evaluate self, "_ = IRB.CurrentContext.last_value"
- if @eval_history #and !@eval_history_values.equal?(llv)
+ if (@eval_history ||= nil) #and !@eval_history_values.equal?(llv)
@eval_history_values.push @line_no, @last_value
@workspace.evaluate self, "__ = IRB.CurrentContext.instance_eval{@eval_history_values}"
end
@@ -33,7 +33,7 @@ module IRB
attr_reader :eval_history
def eval_history=(no)
if no
- if @eval_history
+ if (@eval_history ||= nil)
@eval_history_values.size(no)
else
@eval_history_values = History.new(no)
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index 491aa027ca..8e9b01673c 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -203,6 +203,7 @@ module IRB
def CE.def_extend_command(cmd_name, load_file, *aliases)
Context.module_eval %[
def #{cmd_name}(*opts, &b)
+ Context.module_eval {remove_method(:#{cmd_name})}
require "#{load_file}"
send :#{cmd_name}, *opts, &b
end
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
index 8b6ff6264d..ad53a303f8 100644
--- a/lib/irb/init.rb
+++ b/lib/irb/init.rb
@@ -97,7 +97,7 @@ module IRB
}
}
- @CONF[:PROMPT_MODE] = :DEFAULT
+ @CONF[:PROMPT_MODE] = (STDIN.tty? ? :DEFAULT : :NULL)
@CONF[:AUTO_INDENT] = false
@CONF[:CONTEXT_MODE] = 3 # use binding in function on TOPLEVEL_BINDING
@@ -123,11 +123,11 @@ module IRB
@CONF[:MATH_MODE] = true
when "-d"
$DEBUG = true
- when "-r"
- opt = ARGV.shift
+ when /^-r(.+)?/
+ opt = $1 || ARGV.shift
@CONF[:LOAD_MODULES].push opt if opt
- when "-I"
- opt = ARGV.shift
+ when /^-I(.+)?/
+ opt = $1 || ARGV.shift
$LOAD_PATH.push opt if opt
when /^-K(.)/
$KCODE = $1
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb
index b2c90e38e2..351406c2da 100644
--- a/lib/irb/locale.rb
+++ b/lib/irb/locale.rb
@@ -10,7 +10,6 @@
#
#
-autoload :Tempfile, "tempfile"
autoload :Kconv, "kconv"
module IRB
@@ -126,15 +125,12 @@ module IRB
end
def real_load(path, priv)
- tmp_base = path.tr("./:", "___")
- lc_file = Tempfile.new(tmp_base)
- File.foreach(path) do |line|
- line = self.String(line)
- lc_file.print(line)
+ src = self.String(File.read(path))
+ if priv
+ eval("self", TOPLEVEL_BINDING).extend(Module.new {eval(src, nil, path)})
+ else
+ eval(src, TOPLEVEL_BINDING, path)
end
- lc_file.close
- toplevel_load lc_file.path, priv
- lc_file.close(true)
end
private :real_load
diff --git a/lib/irb/slex.rb b/lib/irb/slex.rb
index c0943f6e33..f729721a58 100644
--- a/lib/irb/slex.rb
+++ b/lib/irb/slex.rb
@@ -116,7 +116,6 @@ class SLex
def create_subnode(chrs, preproc = nil, postproc = nil)
if chrs.empty?
if @postproc
- p node
SLex.fail ErrNodeAlreadyExists
else
print "Warn: change abstract node to real node\n" if SLex.debug?