Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary string formatting for sshCommand #626

Merged

Conversation

asgorobets
Copy link
Contributor

@asgorobets asgorobets commented Sep 20, 2017

Overview

This pull request:

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

Summary

SshCommand is using sprintf to return a formatted command, but it's not actually sing any variables and basically just relies on inline variable interpolation. I think it is redundant and it's creating some other issues with string formatting, as now you have to escape your % characters in your options.

Description

Please see the following usage scenario:

$this->taskSshExec('company.com', 'user')
  ->option('-o', 'ProxyCommand ssh -A -q user@bastion.company.com nc %h %p');

If you use sprintf, you will have to escape all % chars with another %. But since sprintf is not doing any formatting now, I propose to replace it with string interpolation.

Possible breaking change:
This may be a breaking change for someone who already relied on sshCommand and was already escaping the '%' character, they may end up with %% in their custom code

@greg-1-anderson
Copy link
Member

Well, this is definitely an improvement.

@DavertMik, any opinion on the b/c break?

@greg-1-anderson greg-1-anderson merged commit 047af4b into consolidation:master Oct 20, 2017
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.

None yet

2 participants