sh icon indicating copy to clipboard operation
sh copied to clipboard

fileutil: should the Shebang be more generic?

Open mvdan opened this issue 3 years ago • 0 comments

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 return bash -x, where right now it would only return bash. The places where we call Shebang would need to be adjusted.

mvdan avatar Apr 13 '22 19:04 mvdan