Permalink
Browse files

Use Shellwords to more reliably escape subprocess arguments

  • Loading branch information...
purcell committed Aug 24, 2010
1 parent 8c35479 commit 57782975842736021e69617de07920683c7ca87e
Showing with 2 additions and 1 deletion.
  1. +2 −1 darcs-to-git
View
@@ -15,6 +15,7 @@ require 'optparse'
require 'yaml'
require 'pathname'
require 'iconv'
+require 'Shellwords'
# Explicitly setting a time zone would cause darcs to only output in
# that timezone hence we couldn't get the actual patch TZ
@@ -135,7 +136,7 @@ end
def output_of(*args)
puts "Running: #{args.inspect}"
- output = IO.popen(args.map {|a| "\"#{a}\""}.join(' '), 'r') { |p| p.read }
+ output = IO.popen(args.map {|a| Shellwords.shellescape(a) }.join(' '), 'r') { |p| p.read }
if $?.exitstatus == 0
return validate_utf8(output)
else

0 comments on commit 5778297

Please sign in to comment.