This will work for shell shebangs like #!/usr/bin/bash, but not for others like #!/usr/bin/python. There's not really a good reason for it; we just didn't write it that way.
It would be neat if the regular expression was made more generic. It should probably return the entire command, so if the input is #!/usr/bin/bash -x, it would return bash -x, where right now it would only return bash. The places where we call Shebang would need to be adjusted.
Right now, the
Shebang
API uses a shell-specific regular expression:https://github.com/mvdan/sh/blob/43a160083ea11d3d02f66c6ac748ae4c64ab4bc3/fileutil/file.go#L16
This will work for shell shebangs like
#!/usr/bin/bash
, but not for others like#!/usr/bin/python
. There's not really a good reason for it; we just didn't write it that way.It would be neat if the regular expression was made more generic. It should probably return the entire command, so if the input is
#!/usr/bin/bash -x
, it would returnbash -x
, where right now it would only returnbash
. The places where we callShebang
would need to be adjusted.