pre-commit
pre-commit copied to clipboard
Shellcheck does not allow for shebangs with a space
The custom regex check will fail if the shebang is in the format of #! /usr/bin/bash
and only work when removing the space e.g #!/usr/bin/bash
.
Spaces in shebangs are valid.
Do we have a script with a space after the shebang somewhere?
Not in this repo maybe, but if I try to use this hook in a repo it will not work unless removing the space. I tried to test by changing the regex and validating on regexr but I'm not sure which format of regex that is (PCRE?)
Ohhh, I think I misunderstood. What you're saying is that the regex we use to identify shell scripts is what would need to be fixed?
Yep indeed, the regex needs to option to allow a space between right after the bang symbol:
- regex validates:
#!/usr/bin/env bash
- regex invalidates:
#! /usr/bin/env bash
Understood! And, indeed, spaces after shebang are allowed, as you mentioned. Would you be up for a PR to tweak the regex?
Yeah sure, do you know what format the regex is? I tried it on regexr but it didn't validate. Maybe its perl regex?
It's grep format: https://stackoverflow.com/a/4192817/483528.