Permalink
Browse files

be more explicitly about what operations are going on on the shell words

  • Loading branch information...
copiousfreetime committed Jul 17, 2011
1 parent 5dfc78a commit b65d9eee651a35639392167a87b4e92ed78cda99
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/launchy/detect/runner.rb
@@ -23,11 +23,16 @@ def self.detect
#
# cut it down to just the shell commands that will be passed to exec or
- # posix_spawn.
+ # posix_spawn. The cmd argument is split according to shell rules and the
+ # args are escaped according to shell rules.
+ #
def shell_commands( cmd, args )
- cmds = [ cmd.shellsplit, args.collect{ |a| a.to_s } ].flatten.find_all { |a| not a.nil? and a.size > 0 }
- Launchy.log "ARGV => #{cmds.inspect}"
- return cmds
+ cmdline = [ cmd.shellsplit ]
+ cmdline << args.collect{ |a| a.to_s.shellescape }
+ cmdline.flatten!
+ cmdline = cmdline.find_all { |a| (not a.nil?) and ( a.size > 0 ) }
+ Launchy.log "ARGV => #{cmdline.inspect}"
+ return cmdline
end
def run( cmd, *args )

0 comments on commit b65d9ee

Please sign in to comment.