capistrano / capistrano/sshkit
Bug: within(directory){ execute(string) } should either 'just work' or 'boom'
- Dominant language
- Ruby
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
docs aren't good enough to explain the design choice IMHO - just check
stackoverflow...
one solution is just to fix it - use shellwords to properly escape the command
``` ruby
require 'shellwords'
def execute(*args, &block)
if args.first.is_a?(String)
command = Shellwords.escape(args.first)
end
# ...
end
```
otherwise raise an exception
``` ruby
def execute(*args, &block)
if args.first.is_a?(String) and inside_within?
raise "don't do that"
end
# ...
end
```
the current behavior of doing
``` ruby
within directory do # silently ignored
execute command
end
```
just isn't POLS - the point of a library like cap is to be able to re-use code
but, currently, each and every use must re-invent 'cd into a (properly escaped
directory) and run commands', including handling the fact that
``` ruby
within(does_not_exist) do # raises
end
```
``` ruby
execute "#{ does_not_exist }; command.sh" # reports a failed exit status that leads to debugging which part failed
```
a final solution would be to remove the 'within' API since it sometimes works,
and sometimes does not, issuing no exception nor warning
Contributor guide
Assessment
This issue has not been assessed yet.