Skip to content

Commit

Permalink
Add 'sudo_opts' to Process to allow sudo options to be set for sudo c…
Browse files Browse the repository at this point in the history
…ommands
  • Loading branch information
vitorbrandao committed Mar 16, 2012
1 parent 6756b6e commit 229e595
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/NoiseLabs/ToolKit/Runner/Process.php
Expand Up @@ -47,6 +47,9 @@ class Process implements ProcessInterface
* 'sudo': * 'sudo':
* If TRUE, prepend every command with 'sudo'. * If TRUE, prepend every command with 'sudo'.
* *
* 'sudo_opts':
* sudo options
*
* 'cwd': * 'cwd':
* The initial working dir for the command. This must be an absolute * The initial working dir for the command. This must be an absolute
* directory path, or NULL if you want to use the default value (the * directory path, or NULL if you want to use the default value (the
Expand All @@ -65,6 +68,7 @@ class Process implements ProcessInterface
*/ */
protected $_defaults = array( protected $_defaults = array(
'sudo' => false, 'sudo' => false,
'sudo_opts' => '-n', // non-interactive
'cwd' => null, 'cwd' => null,
'env' => null, 'env' => null,
'dry-run' => false 'dry-run' => false
Expand Down Expand Up @@ -189,7 +193,7 @@ public function run()


// use sudo? // use sudo?
$command = (true === $this->settings->get('sudo', $this->_defaults['sudo'])) ? $command = (true === $this->settings->get('sudo', $this->_defaults['sudo'])) ?
'sudo '.$this->command : $this->command; 'sudo '.$this->settings->get('sudo_opts', $this->_defaults['sudo_opts']).' '.$this->command : $this->command;


// current working directory // current working directory
$cwd = $this->settings->get('cwd', $this->_defaults['cwd']); $cwd = $this->settings->get('cwd', $this->_defaults['cwd']);
Expand Down

0 comments on commit 229e595

Please sign in to comment.