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

style: set shell variables in hash #7696

Merged
merged 1 commit into from Jun 27, 2020

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Jun 5, 2020

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

When running Utils.popen (or similar popen command), having a line like "SHELL=bash ..." doesn't work properly. Instead, using `Utils.popen({ "SHELL" => "bash" }, "...") works correctly.

See Homebrew/homebrew-core#55682 for more info. This comment may also be helpful.

Example: Utils.safe_popen_read "SHELL=bash foo" becomes Utils.safe_popen_read({ "SHELL" => "bash" }, "foo")


Here is a concern of mine: in doitlive, running the audit on the line

Utils.popen_read("SHELL=bash #{libexec}/bin/doitlive completion")

says to change to

Utils.popen_read({ "SHELL" => "bash" }, "#{libexec}/bin/doitlive completion")

when the correct line is actually

Utils.safe_popen_read({ "SHELL" => "bash" }, libexec/"bin/doitlive", "completion")

I think this is okay because, once #7691 and #7695 are merged, separate audit statements will recomend changing popen_read to safe_popen_read, and separating #{libexec}/bin/doitlive completion into its individual arguments.


These formulae will need to be updated to match this new style:

  • doitlive
  • helm
  • helm@2
  • tektoncd-cli

@Rylan12 Rylan12 marked this pull request as draft June 5, 2020 22:53
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looking good so far!

@Rylan12 Rylan12 changed the title audit: use "foo=bar", not {"foo"=>"bar"}, in popen Use "foo=bar", not {"foo"=>"bar"}, in Utils.popen commands Jun 6, 2020
@Rylan12 Rylan12 force-pushed the audit-shell-variables branch 2 times, most recently from f0d9840 to bd5bd54 Compare June 6, 2020 22:05
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Again: great work so far 👏

@Rylan12 Rylan12 self-assigned this Jun 24, 2020
@Rylan12 Rylan12 changed the title Use "foo=bar", not {"foo"=>"bar"}, in Utils.popen commands style: set shell variables in Hash Jun 24, 2020
@Rylan12
Copy link
Member Author

Rylan12 commented Jun 24, 2020

Todo:

@Rylan12 Rylan12 force-pushed the audit-shell-variables branch 2 times, most recently from 9de4813 to a89936b Compare June 24, 2020 20:56
@Rylan12 Rylan12 removed their assignment Jun 24, 2020
@Rylan12 Rylan12 force-pushed the audit-shell-variables branch 2 times, most recently from bbce16e to 606db89 Compare June 25, 2020 21:30
@Rylan12 Rylan12 changed the title style: set shell variables in Hash style: set shell variables in hash Jun 25, 2020
@Rylan12 Rylan12 marked this pull request as ready for review June 25, 2020 22:14
@Rylan12 Rylan12 requested a review from MikeMcQuaid June 25, 2020 22:15
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looking good so far! One question.

Library/Homebrew/rubocops/lines.rb Outdated Show resolved Hide resolved
When running Utils.popen (or similar popen command), having a line like
"SHELL=bash ..." doesn't work properly. Instead, use:
`Utils.popen({ "SHELL" => "bash" }, "...")`
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks good, nice work again @Rylan12!

@MikeMcQuaid MikeMcQuaid merged commit 21069e3 into Homebrew:master Jun 27, 2020
@Rylan12 Rylan12 deleted the audit-shell-variables branch June 27, 2020 14:00
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 27, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 27, 2020
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.

None yet

3 participants