Class: Launchy::Detect::Runner::Windows

Inherits:
Launchy::Detect::Runner show all
Defined in:
lib/launchy/detect/runner.rb

Overview


The list of known runners


Instance Method Summary collapse

Methods inherited from Launchy::Detect::Runner

#commandline_normalize, detect, #run

Methods included from Launchy::DescendantTracker

#children, #find_child, #inherited

Instance Method Details

#all_args(cmd, *args) ⇒ Object



72
73
74
75
76
# File 'lib/launchy/detect/runner.rb', line 72

def all_args( cmd, *args )
  args = [ 'cmd', '/c', *shell_commands( cmd, *args ) ]
  Launchy.log "Windows: all_args => #{args.inspect}"
  return args
end

#dry_run(cmd, *args) ⇒ Object



78
79
80
# File 'lib/launchy/detect/runner.rb', line 78

def dry_run( cmd, *args )
  all_args( cmd, *args ).join(" ")
end

#shell_commands(cmd, *args) ⇒ Object

escape the reserved shell characters in windows command shell technet.microsoft.com/en-us/library/cc723564.aspx

Also make sure that the item after ‘start’ is guaranteed to be quoted. github.com/copiousfreetime/launchy/issues/62



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/launchy/detect/runner.rb', line 87

def shell_commands( cmd, *args )
  parts = cmd.shellsplit

  if start_idx = parts.index('start') then
    title_idx = start_idx + 1
    title     = parts[title_idx]
    title     = title.sub(/^/,'"') unless title[0] == '"'
    title     = title.sub(/$/,'"') unless title[-1] == '"'
    parts[title_idx] = title
  end

  cmdline = [ parts ]
  cmdline << args.flatten.collect { |a| a.to_s.gsub(/([&|()<>^])/, "^\\1") }
  return commandline_normalize( cmdline )
end

#wet_run(cmd, *args) ⇒ Object



103
104
105
# File 'lib/launchy/detect/runner.rb', line 103

def wet_run( cmd, *args )
  system( *all_args( cmd, *args ) )
end