Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit b65d9eee651a35639392167a87b4e92ed78cda99 1 parent 5dfc78a
@copiousfreetime authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 lib/launchy/detect/runner.rb
View
13 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 )
Please sign in to comment.
Something went wrong with that request. Please try again.