-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Shebang #1256
Comments
Hmm, can you use I think the best way to support this would be via an annotation:
|
I have no idea how you get shebang to work on Windows at all when there is no sh.exe available. Does PowerShell support Shebang natively? Your example The annotation sounds like a good option. Especially if the shebang is not handled special by Just before execution on anything other than Windows. I also wouldn't mind #!recipe:
Awesome script code
goes here That could be called with |
On Windows, just actually parses shebang lines itself.
Is there any way to get this to work? On MacOS I was able to create and execute the following script:
|
Huh? Did you put that in a script file or in a Justfile recipe? Also what version of macOS is that and with which shell? I tried that code in both and got #!/usr/local/bin/python3
print('foo') This is on macOS Big Sur using Bash, Zsh, or PowerShell, and has always been the case for me since OS X Tiger. |
Ahh, okay, it for me in a script, but not a justfile, so maybe my shell (zsh) is doing some special magic to make it work. Okay, here's a more complete sketch for how this could work. Recipes with the
What do you think? |
Yeah, it's probably something that is part of Oh My Zsh if you're using that. I haven't got that in my Zsh setup. Other than that, sounds good to me! 😁 |
I think this answers the original question. Although I was really hoping to use a conditional when using SHEBANG := if os_family() == "windows" { "powershell.exe" } else { "/usr/bin/env pwsh" }
echo:
#!{{ SHEBANG }}
echo $PSVersionTable Tested on Windows and Ubuntu (WSL) using different PowerShell versions. |
Hey @AceofSpades5757 that's what we worked out in #1293. Great minds think alike! 😃 |
I'd like to use PowerShell as the only shell and scripting language in Just as it is available on Linux and Mac as well as Windows. The one thing that kills that is the shebang. The traditional shebang requires a full path to the executable. For many languages you would just have
#!/usr/bin/env interpreter
but/usr/bin/env
or evenenv
does not exist on Windows. I need the ability to tell Just that the recipe is a script without using a shebang. I also don't desire to use or expect and can use\
at the end of lines to continue some gargantuan one-liner in this context. A possible solution would be allowing#!default
as the shebang to trigger the default shell (in this caseset shell := ["pwsh", "-NoLogo", "-Command"]
) in scripting mode. I apologize if that is already a feature in some fashion and missed it.The text was updated successfully, but these errors were encountered: