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

[Feature request] Add Lint for shellcheck #691

Open
zeehio opened this issue Jan 5, 2021 · 0 comments · May be fixed by #692
Open

[Feature request] Add Lint for shellcheck #691

zeehio opened this issue Jan 5, 2021 · 0 comments · May be fixed by #692

Comments

@zeehio
Copy link

zeehio commented Jan 5, 2021

Problem

Many recipes have shell scripts (e.g. build.sh, post-link.sh, pre-unlink.sh). Some of those scripts have portability issues, such as:

  • do not have a shebang. example
  • do not quote directories example (conda already warns about avoiding spaces, but anyway better safe than sorry)
  • Have bashisms even if they are declared as /bin/sh scripts example
  • ...

This makes those scripts fragile, or lead to unwanted effects.

For instance, if a user installs a package on a conda environment with spaces, like /path/with spaces a post installation script like:

#!/bin/sh
DIR="/path/with spaces"
# whatever work done here
rm -rf $DIR

will remove "/path/with" and "spaces" instead of "/path/with spaces"

More dangerously could be a path with a trailing space:

#!/bin/sh

#DIR="/path/with-a-trailing-space /"
#rm -rf $DIR

Which I have commented out because you do not want to remove / by accident.

Solution: shellcheck

shellcheck is a tool that checks shell scripts and looks for potential and common errors. See more bad-code examples here: https://github.com/koalaman/shellcheck/blob/master/README.md#gallery-of-bad-code

It is widely available (as a debian package, installable through brew on osx and on conda-forge).

Linting bioconda scripts with shellcheck could prevent many of those issues.

shellcheck recipes/bioconductor-dapardata/*.sh

imatge

It would be great to try to have an integrated linter in bioconda to detect those issues and suggest corrections.

@zeehio zeehio linked a pull request Jan 6, 2021 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant