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

New cop: system vs sh #26

Open
pocke opened this issue Dec 13, 2019 · 0 comments
Open

New cop: system vs sh #26

pocke opened this issue Dec 13, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@pocke
Copy link
Collaborator

pocke commented Dec 13, 2019

In Rake task, I prefer sh to system to execute external commands.
Because sh raises an error when the command exits with non-zero. It is safer.

task :foo do
  system 'false' # It does not raise any errors
  sh 'false' # It raises an error.
end

Note: I think system in not void context is ok. So the cop should not add any offense for the following code.

task :foo do
  # It does not raise, but handled.
  if system 'cmd'
    # ...
  end
end
@pocke pocke added the enhancement New feature or request label Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant