Skip to content

cmd/prof: raise error when cmd is bash file#10280

Merged
MikeMcQuaid merged 2 commits intoHomebrew:masterfrom
hyuraku:cmd/commands_add_only_bash_command_list
Jan 18, 2021
Merged

cmd/prof: raise error when cmd is bash file#10280
MikeMcQuaid merged 2 commits intoHomebrew:masterfrom
hyuraku:cmd/commands_add_only_bash_command_list

Conversation

@hyuraku
Copy link
Copy Markdown
Contributor

@hyuraku hyuraku commented Jan 10, 2021

  • 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 typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?
  • Have you successfully run brew man locally and committed any changes?

brew prof update caused an error because update is made by bash, not ruby. However, the error message Error: Unknown command: update was not correct, so I added the correct message.

brew prof update
Error: Unknown command: update
Error: Failure while executing; `/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby /usr/local/Homebrew/Library/Homebrew/brew.rb update` exited with 1.

@hyuraku hyuraku changed the title cmd/commands: add_only_bash_command_list cmd/commands: add only bash command list Jan 10, 2021
Copy link
Copy Markdown
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.

Thanks @hyuraku! some comments.

end

def only_bash_command_list
internal_commands.reject { |cmd| valid_internal_cmd?(cmd) }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this function makes sense but not the implementation. This should check for a file extension instead.

end
exec "brew-#{cmd}", *ARGV
else
raise "command made by bash not ruby: #{cmd}" if Commands.only_bash_command_list.include?(cmd)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It doesn't seem like this should be in brew.rb but prof.rb instead.

@hyuraku hyuraku changed the title cmd/commands: add only bash command list cmd/prof: raise error when cmd is bash file Jan 11, 2021
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
raise "#{cmd} is made by bash not ruby" if Commands.path(cmd).extname == ".sh"
raise UsageError, "#{cmd} is a Bash command!" if Commands.path(cmd).extname == ".sh"

@hyuraku hyuraku force-pushed the cmd/commands_add_only_bash_command_list branch from 76f1a7c to c56fff3 Compare January 11, 2021 12:02
@hyuraku
Copy link
Copy Markdown
Contributor Author

hyuraku commented Jan 17, 2021

@MikeMcQuaid
Could you review this PR again?

@MikeMcQuaid
Copy link
Copy Markdown
Member

Thanks again @hyuraku!

@MikeMcQuaid MikeMcQuaid merged commit 668073d into Homebrew:master Jan 18, 2021
@hyuraku hyuraku deleted the cmd/commands_add_only_bash_command_list branch January 18, 2021 14:29
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Feb 18, 2021
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Feb 18, 2021
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.

3 participants