diff options
author | aycabta <[email protected]> | 2019-08-06 20:28:48 +0900 |
---|---|---|
committer | aycabta <[email protected]> | 2019-08-06 20:28:48 +0900 |
commit | 43b52ac0a52807c415e9d24d25954f5055567c5e (patch) | |
tree | c22b2efe4c6d780bc7510e09f75d8885f9d415ab /lib/irb.rb | |
parent | 1ee88c51b3c319b74b69540e111e4a1c24833cad (diff) |
Revert "Don't echo results of assignment expressions"
This reverts commit 1ee88c51b3c319b74b69540e111e4a1c24833cad.
Diffstat (limited to 'lib/irb.rb')
-rw-r--r-- | lib/irb.rb | 44 |
1 files changed, 1 insertions, 43 deletions
diff --git a/lib/irb.rb b/lib/irb.rb index a41d4e13be..a08aa874c9 100644 --- a/lib/irb.rb +++ b/lib/irb.rb @@ -10,7 +10,6 @@ # # require "e2mmap" -require "ripper" require "irb/init" require "irb/context" @@ -411,35 +410,6 @@ module IRB end class Irb - ASSIGNMENT_NODE_TYPES = [ - # Local, instance, global, class, constant, instance, and index assignment: - # "foo = bar", - # "@foo = bar", - # "$foo = bar", - # "@@foo = bar", - # "::Foo = bar", - # "a::Foo = bar", - # "Foo = bar" - # "foo.bar = 1" - # "foo[1] = bar" - :assign, - - # Operation assignment: - # "foo += bar" - # "foo -= bar" - # "foo ||= bar" - # "foo &&= bar" - :opassign, - - # Multiple assignment: - # "foo, bar = 1, 2 - :massign, - ] - # Note: instance and index assignment expressions could also be written like: - # "foo.bar=(1)" and "foo.[]=(1, bar)", when expressed that way, the former - # be parsed as :assign and echo will be suppressed, but the latter is - # parsed as a :method_add_arg and the output won't be suppressed - # Creates a new irb session def initialize(workspace = nil, input_method = nil, output_method = nil) @context = Context.new(self, workspace, input_method, output_method) @@ -528,7 +498,7 @@ module IRB begin line.untaint @context.evaluate(line, line_no, exception: exc) - output_value if @context.echo? && (@context.echo_on_assignment? || !assignment_expression?(line)) + output_value if @context.echo? rescue Interrupt => exc rescue SystemExit, SignalException raise @@ -747,18 +717,6 @@ module IRB format("#<%s: %s>", self.class, ary.join(", ")) end - def assignment_expression?(line) - # Try to parse the line and check if the last of possibly multiple - # expressions is an assignment type. - - # If the expression is invalid, Ripper.sexp should return nil which will - # result in false being returned. Any valid expression should return an - # s-expression where the second selement of the top level array is an - # array of parsed expressions. The first element of each expression is the - # expression's type. - ASSIGNMENT_NODE_TYPES.include?(Ripper.sexp(line)&.dig(1,-1,0)) - end - ATTR_TTY = "\e[%sm" def ATTR_TTY.[](*a) self % a.join(";"); end ATTR_PLAIN = "" |