-
Notifications
You must be signed in to change notification settings - Fork 7
Description
If the input contains a #!/bin/sh shebang, it currently outputs as #!/bin/sh, this populates fish scripts with the wrong shebangs. It'd be great if we could use #!/usr/bin/env fish instead.
In fish, shebangs are not strictly necessary in many scenarios:
The shebang line is only used when scripts are executed without specifying the interpreter. For functions inside fish or when executing a script with fish
/path/to/script, a shebang is not required (but it doesn’t hurt!).
— See Introduction — Shebang Line — fish-shell documentation
Ideally, we'd only emit #!/usr/bin/env fish if the first line is a valid shebang (#!/bin/sh, #!/bin/bash, #!/usr/bin/env bash, etc.), and not emit said shebang if the input lacks one. Additionally, we could preserve the empty line after the shebang.
Examples
Currently, a file:
#!/bin/sh
f() {
echo 'This is the f function'
}Will emit:
#!/bin/sh
function f
echo 'This is the f function'
endInstead of the desired:
#!/usr/bin/env fish
function f
echo 'This is the f function'
end