From be9b77d6a9af7089c113c240118c237944c926c1 Mon Sep 17 00:00:00 2001 From: John Mair Date: Fri, 10 Jun 2011 22:46:46 +1200 Subject: [PATCH] trying to fix interpolation --- lib/pry/command_processor.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/pry/command_processor.rb b/lib/pry/command_processor.rb index 647dada3..3adf18d0 100644 --- a/lib/pry/command_processor.rb +++ b/lib/pry/command_processor.rb @@ -55,11 +55,18 @@ class Pry def command_matched(val, target) _, cmd_data = commands.commands.find do |name, data| - interp_val = interpolate_string(val, target) command_regex = /^#{convert_to_regex(name)}(?!\S)/ - if data.options[:interpolate] && (command_regex =~ interp_val) - val.replace interp_val + if data.options[:interpolate] + # If interpolation fails then the command cannot be matched, + # so early exit. + begin + interp_val = interpolate_string(val, target) + rescue NameError + return nil + end + + val.replace interp_val if command_regex =~ interp_val else command_regex =~ val end