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

Perils of rm -fr $builddir #22

Open
rpdelaney opened this issue Feb 12, 2019 · 0 comments
Open

Perils of rm -fr $builddir #22

rpdelaney opened this issue Feb 12, 2019 · 0 comments

Comments

@rpdelaney
Copy link

Thanks for this. I was recently lamenting the lack of anything like this tool.

rm -rf $builddir

This is dangerous.

  1. Since $builddir isn't quoted, chaos will ensue if this ever becomes subject to word splitting for any reason. C.f.: bumblebeee
  2. since you don't have set -u, who knows what will happen if the variable is unset when we get to this point? C.f.: steam-for-linux and shellcheck (I'm not really recommending set -u btw)
  3. Globs and wildcards in the path will be expanded by the shell before rm is called, leading to some kind of apocalypse probably.

You may think that the code as-written can't be subject to such problems. But a future refactoring elsewhere could render this unsafe.

If you agree I can send a PR adding some safety catches. What do you think?

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

No branches or pull requests

1 participant