capistrano/capistrano — pull request #506 by eugeneliskovets (2013-06-14 06:38:57+00:00)
Title: Issue with try_sudo deploy:cleanup

When I was trying to use sudo for deploy via my deploy user I've found a bug.
It request the password and said that password was incorrect. The cause of that is shell request for password twice (I tried to run this command myself from production server).
I've attached log for this error.
```
cap production deploy:cleanup
triggering load callbacks
* 2013-06-14 10:30:40 executing `production'
triggering before callbacks for `production'
triggering start callbacks for `deploy:cleanup'
* 2013-06-14 10:30:40 executing `multistage:ensure'
* 2013-06-14 10:30:40 executing `deploy:cleanup'
* executing multiple commands in parallel
-> "else" :: "sudo -p 'sudo password: ' -u deployuser ls -1dt /home/deployuser/deploy/releases/* | tail -n +6 | sudo -p 'sudo password: ' -u deployuser xargs rm -rf"
-> "else" :: "sudo -p 'sudo password: ' -u deployuser ls -1dt /home/deployuser/deploy/releases/* | tail -n +6 | sudo -p 'sudo password: ' -u deployuser xargs rm -rf"
servers: ["PC1", "PC2"]
[el@PC2] executing command
[el@PC1] executing command
Password:
** [out :: el@PC1]
** [out :: el@PC2]
*** [out :: el@PC1] Sorry, try again.
** [out :: el@PC1] Sorry, try again.
Password:
** [out :: el@PC2] Sorry, try again.
** [out :: el@PC1]
** [out :: el@PC2]
*** [out :: el@PC1] Sorry, try again.
** [out :: el@PC1] Sorry, try again.
Password:
** [out :: el@PC1]
** [out :: el@PC2] Sorry, try again.
** [out :: el@PC2]
** [out :: el@PC2] Sorry, try again.
** [out :: el@PC2] sudo: 3 incorrect password attempts
*** [out :: el@PC1] Sorry, try again.
** [out :: el@PC1] Sorry, try again.
Password:
** [out :: el@PC1]
*** [out :: el@PC1] Sorry, try again.
** [out :: el@PC1] Sorry, try again.
Password:
** [out :: el@PC1]
*** [out :: el@PC1] Sorry, try again.
*** [out :: el@PC1] sudo: 3 incorrect password attempts
** [out :: el@PC1] Sorry, try again.
** [out :: el@PC1] sudo: 3 incorrect password attempts
```
I've moved it to one shell command with try_sudo.