[Instruments] Ensure we only deal with the templates part of the output.

This commit is contained in:
Eloy Durán
2014-08-18 13:09:26 +02:00
committed by Watson
parent a151f34607
commit f96299978c

View File

@@ -301,7 +301,12 @@ EOS
if File.exist?(template)
template_path = template
elsif !builtin_templates.grep(/#{template}/i).empty?
list = `#{locate_binary('instruments')} -s 2>&1`.strip.split("\n").map { |line| line.sub(/^\s*"/, '').sub(/",*$/, '') }
# Get a list of just the templates (ignoring devices)
list = `#{locate_binary('instruments')} -s 2>&1`.strip.split("\n")
start = list.index('Known Templates:') + 1
list = list[start..-1]
# Only interested in the template (file base) names
list.map! { |line| line.sub(/^\s*"/, '').sub(/",*$/, '') }
template = template.downcase
template_path = list.find { |path| File.basename(path, File.extname(path)).downcase == template }
else