Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Bug: within(directory){ execute(string) } should either 'just work' or 'boom'

Open
#306 12 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
ruby
Domain
devops

Research direction

Start by reading the existing within and execute entry points and the documentation around them, then reproduce the silently ignored directory behavior and the failing-directory contrast described here. Resolve the design choice between making string commands work, raising, or removing within, and document and test the selected behavior.

Written by the indexing model from the issue text.

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

  require 'shellwords'

  def execute(*args, &block)
    if args.first.is_a?(String)
      command = Shellwords.escape(args.first)
    end

    # ...
  end

otherwise raise an exception

  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

  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

  within(does_not_exist) do # raises
  end
  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

Dominant language
Ruby
Stars
1.2k
Forks
257
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from capistrano/sshkit

All issues in capistrano/sshkit

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.