Skip to content

Commit

Permalink
fix: remove eval from lib/gzr/commands/role/ls.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
drstrangelooker committed Nov 7, 2023
1 parent 2b36a27 commit fae96e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 3 additions & 0 deletions lib/gzr/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ def field_expressions_eval(expressions, data)
current = nil
end
end
if current.kind_of? Array
current = current.join("\n")
end
current
end
end
Expand Down
7 changes: 1 addition & 6 deletions lib/gzr/commands/role/ls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,8 @@ def execute(input: $stdin, output: $stdout)
table_hash = Hash.new
fields = field_names(@options[:fields])
table_hash[:header] = fields unless @options[:plain]
expressions = fields.collect { |fn| field_expression_hash(fn) }
table_hash[:rows] = data.map do |row|
expressions.collect do |e|
v = eval "row#{e}"
next (v.join "\n") if v.kind_of? Array
v
end
field_expressions_eval(fields,row)
end
table = TTY::Table.new(table_hash)
alignments = fields.collect do |k|
Expand Down

0 comments on commit fae96e7

Please sign in to comment.