Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7388

Show
Ignore:
Timestamp:
09/01/07 03:31:53 (10 months ago)
Author:
minam
Message:

Set :shell to false to run a command without wrapping it in "sh -c" (closes #9290)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/capistrano/CHANGELOG

    r7387 r7388  
    11*SVN* 
     2 
     3* Set :shell to false to run a command without wrapping it in "sh -c" [Jamis Buck] 
    24 
    35* Don't request a pty by default [Jamis Buck] 
  • tools/capistrano/lib/capistrano/command.rb

    r7387 r7388  
    8787            execute_command = Proc.new do |ch| 
    8888              logger.trace "executing command", ch[:server] if logger 
    89               escaped = replace_placeholders(command, ch).gsub(/[$\\`"]/) { |m| "\\#{m}" } 
    90               command_line = [environment, options[:shell] || "sh", "-c", "\"#{escaped}\""].compact.join(" ") 
     89              cmd = replace_placeholders(command, ch) 
     90 
     91              if options[:shell] == false 
     92                shell = nil 
     93              else 
     94                shell = "#{options[:shell] || "sh"} -c" 
     95                cmd = cmd.gsub(/[$\\`"]/) { |m| "\\#{m}" } 
     96                cmd = "\"#{cmd}\"" 
     97              end 
     98 
     99              command_line = [environment, shell, cmd].compact.join(" ") 
     100 
    91101              ch.exec(command_line) 
    92102              ch.send_data(options[:data]) if options[:data] 
  • tools/capistrano/test/command_test.rb

    r7387 r7388  
    111111    end 
    112112    Capistrano::Command.new("ls", [session], :shell => "/bin/bash") 
     113  end 
     114 
     115  def test_successful_channel_with_shell_false_should_send_command_without_shell 
     116    session = setup_for_extracting_channel_action do |ch| 
     117      ch.expects(:exec).with(%(echo `hostname`)) 
     118    end 
     119    Capistrano::Command.new("echo `hostname`", [session], :shell => false) 
    113120  end 
    114121