Skip to content

Escape SSH commands correctly#954

Closed
prudloff-insite wants to merge 2 commits into
consolidation:1.xfrom
prudloff-insite:escape-ssh
Closed

Escape SSH commands correctly#954
prudloff-insite wants to merge 2 commits into
consolidation:1.xfrom
prudloff-insite:escape-ssh

Conversation

@prudloff-insite

Copy link
Copy Markdown
Contributor

Overview

This pull request:

  • Fixes a bug
  • Adds a feature
  • Breaks backwards compatibility
  • Has tests that cover changes
  • Adds or fixes documentation

Summary

This changes the way SSH commands are escaped in order to work with commands containing '.

Description

Consider the following code:

    $gitTask = $this->taskGitStack()
      ->commit('foo bar');

    $this->taskSshExec()
      ->exec($gitTask)
      ->run();

Without this patch, it will produce (which will fail):

ssh server 'cd "/path/" && git commit -m 'foo bar''

And with the patch:

ssh server 'cd "/path/" && git commit -m '\''foo bar'\'''

(Now the Git message is escaped correctly.)

Sorry, we are still stuck on Robo 1.4.12 but I would understand if you didn't want to merge a fix on this old branch.

@greg-1-anderson

Copy link
Copy Markdown
Member

This looks good, but it will need to go in on the default branch first. The code should be about the same there.

Only escape if needed
@prudloff-insite prudloff-insite changed the base branch from 1.x to 3.x December 19, 2022 16:35
@prudloff-insite prudloff-insite changed the base branch from 3.x to 1.x December 19, 2022 16:36
@prudloff-insite

Copy link
Copy Markdown
Contributor Author

There is a PR for the 3.x branch here: #989

@prudloff-insite

Copy link
Copy Markdown
Contributor Author

1.x is not supported anymore.
Replaced by #989.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants