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 Rule: Executables must start with #!/bin/bash and a minimum number of flags. #2953

Open
2 of 4 tasks
stdedos opened this issue Mar 25, 2024 · 0 comments
Open
2 of 4 tasks

Comments

@stdedos
Copy link
Contributor

stdedos commented Mar 25, 2024

For bugs

For new checks and feature suggestions

Here's a snippet or screenshot that shows the problem:

#!/bin/bash -eu
#!/usr/bin/env bash -x
# This script violates best practices by specifying options directly in the shebang line.
# The -e option causes the script to exit immediately if a command exits with a non-zero status.
# The -u option causes the script to exit if an attempt is made to use an uninitialized variable.

echo "This script has bash options in the shebang, which is not recommended."

Here's what shellcheck currently says:

$ shellcheck myscript
No issues detected!

$

Here's what I wanted or expected to see:

$ shellcheck myscript
 
[Line 1:]()
#!/bin/bash -eu
^-- [SC2xxx](https://www.shellcheck.net/wiki/SCxxxx) (warning): Executables must start with `#!/bin/bash` and a minimum number of flags. Use `set` to set shell options so that calling your script as` bash script_name` does not break its functionality.

$

Suggested by Google Shell Style Guide (https://google.github.io/styleguide/shellguide.html#which-shell-to-use).

There is an error in the same neighbourhood (https://github.com/koalaman/shellcheck/wiki/SC2096)

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