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

too many valid shebangs #373

Closed
izabera opened this issue May 6, 2015 · 4 comments
Closed

too many valid shebangs #373

izabera opened this issue May 6, 2015 · 4 comments

Comments

@izabera
Copy link

izabera commented May 6, 2015

can shellcheck warn for these?

#!/bin/bash/
#!bash
#!env bash
#!/bin/bash /a/b/c
@bittorf
Copy link

bittorf commented May 7, 2015

what is wrong with the last one? in OpenWrt we use e.g.

#!/bin/sh /etc/rc.common

@deryni
Copy link

deryni commented May 8, 2015

#!/bin/sh /some/file will run the file listed in the shebang and not the contents of the file containing that shebang.

That seems unlikely to be what someone intends there.

Unless the rest of the original file is empty or the listed file expects this and can find and run the original file too (looks like maybe BASH_ARGV can help with that?).

@Gandalf-
Copy link
Contributor

Gandalf- commented Jan 1, 2019

Some of these issues appear to have been addressed elsewhere.

Shebang must be an absolute path

Someone could still make a change to catch a trailing slash; eg #!/bin/bash/ since a directory isn't executable

$ ./ShellCheck
sh: 5: ./ShellCheck: Permission denied

In the case of #!/bin/sh /some/file, we can't know if /some/file is accessible to us unless there's an include directive. The script could be written for a different system that has the file, while the system shellcheck is running on doesn't have it.

@koalaman
Copy link
Owner

Yes it can! With this last fix, all of these have warnings, plus some other variations like !#/bin/sh. The exception is the last one, for the reason bittorf mentions.

Thanks for the suggestion and your patience!

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

5 participants