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

service: correctly quote arguments. #15875

Merged
merged 1 commit into from Aug 16, 2023

Conversation

MikeMcQuaid
Copy link
Member

If you have a run argument with a space in it: it will need to be quoted to be passed through correctly when run as a manual command.

Will allow removing manual quoting differences e.g. in https://github.com/Homebrew/homebrew-core/blob/66ebc5d0f0c0df80d96e901b94d4bcf5bc900534/Formula/n/nginx.rb#L149-L153

Fixes #15871.

@@ -399,6 +399,7 @@ def manual_command
.map { |k, v| "#{k}=\"#{v}\"" }

out = vars + command if command?
out.map! { |arg| arg.include?(" ") ? "'#{arg}'" : arg }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe sh_quote is better?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that outputs /opt/homebrew/opt/nginx/bin/nginx -g daemon\ off\; which looks less pretty to be but is correct I guess?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed in 60cdc60

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that one is correct, I believe it should be /opt/homebrew/opt/nginx/bin/nginx -g 'daemon off;'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SMillerDev these two are equivalent

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe nginx specifically complained. But if you say it works that's fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SMillerDev yeh, seems to work fine here, both work the same.

If you have a run argument with a space in it: it will need to be quoted
to be passed through correctly when run as a manual command.

Fixes #15871.
@MikeMcQuaid MikeMcQuaid merged commit 2038481 into Homebrew:master Aug 16, 2023
24 checks passed
@MikeMcQuaid MikeMcQuaid deleted the service_quote_args branch August 16, 2023 11:25
github-merge-queue bot pushed a commit to Homebrew/homebrew-core that referenced this pull request Aug 23, 2023
As-of Homebrew/brew#15875 being merged and
tagged: this will no longer be needed.
@github-actions github-actions bot added the outdated PR was locked due to age label Sep 16, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect "run" instructions for arguments that require escaping/quoting
3 participants