lib/rbbt/util/cmd.rb in rbbt-util-5.21.115 vs lib/rbbt/util/cmd.rb in rbbt-util-5.21.116
- old
+ new
@@ -4,20 +4,23 @@
module CMD
def self.process_cmd_options(options = {})
string = ""
options.each do |option, value|
+ raise "Invalid option key: #{option.inspect}" if option.to_s !~ /^[a-z_0-9\-=]+$/i
+ raise "Invalid option value: #{value.inspect}" if value.to_s.include? "'"
+
case
when value.nil? || FalseClass === value
next
when TrueClass === value
string << "#{option} "
else
if option.to_s.chars.to_a.last == "="
- string << "#{option}#{value} "
+ string << "#{option}'#{value}' "
else
- string << "#{option} #{value} "
+ string << "#{option} '#{value}' "
end
end
end
string.strip
@@ -73,12 +76,10 @@
sin.first.close
STDOUT.reopen sout.last
sout.last.close
-
STDOUT.sync = STDERR.sync = true
-
exec(ENV, cmd)
exit(-1)
rescue Exception