Skip to content

Cross platform shebangs by special-casing #!/usr/bin/env on Windows #1549

@cspotcode

Description

@cspotcode

I can't figure out how to write a cross-platform python or node shebang recipe. #!python works on Windows, and #!/usr/bin/env python works on Linux. But what works on both?

On Linux we can write a reliable shebang using: #!/usr/bin/env bash or #!/usr/bin/env python3

It is expected that /usr/bin/env will always exist at that path, and it will look up the positional argument on your $PATH and call it.

I'm proposing that just can safely special-case this /usr/bin/env prefix on Windows to behave the same: look up the positional argument on your $PATH and execute it. Essentially, on Windows, #!/usr/bin/env whatever will be handled the way it handles #!whatever today.

I can't think of a situation where it is desirable for /usr/bin/env to either do something else on Windows, or to fail with an error. So I don't think special-casing will break anyone's use-case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions