Can't use sudo as an argument in cap shell command #265

Merged
merged 1 commit into from Apr 2, 2013

Projects

None yet

3 participants

@ghost

Leave sudo alone when it is in a position that a command argument uses.

#251

Ken Stailey Can't use sudo as an argument in cap shell command
Leave sudo alone when it is in a position that a command argument uses.

capistrano/capistrano#251
78e5e9b
@travisbot

This pull request passes (merged 78e5e9b into 30a942c).

@carsomyr

@nutznboltz Sorry for the delay. I think I understand the nature of the problem. Unfortunately, I don't think the regex is correct, as not putting the alternator | in a capture group may cause the pattern to ignore the ^. Can you confirm this? The fix would be to enclose the above in a capture group.

@ghost

@carsomyr There are two alternators | one outside of all capture groups and one in a capture group. Sometimes you want to ignore the ^. Consider what happens when you pipe output to sudo e.g. cat foo | sudo.

Did you test it?

Assuming #{configuration.sudo_prompt} is set to Prompt> then tests can be passed to irb like "sudo make me a sandwich".gsub(/^(\s*)sudo\b|([|;&])\s*sudo\b/, "\\0 -p 'Prompt>'") or "test -d / && sudo echo sanity check passed".gsub(/^(\s*)sudo\b|([|;&])\s*sudo\b/, "\\0 -p 'Prompt>'").

Testing that way can you show me an input string that fails? Thanks.

@leehambley leehambley merged commit 2fe158f into capistrano:master Apr 2, 2013

1 check passed

Details default The Travis build passed
@ghost ghost deleted the unknown repository branch Apr 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment