-
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
Document shebang recipe execution in readme #1412
Conversation
3de2362
to
85c00c7
Compare
85c00c7
to
fcb255e
Compare
Thanks for documenting this. There is still a problem on Windows, which probably needs at least documenting, and might need an actual fix. Specifically, if the command in the shebang line, when run on the temporary file, also interprets the shebang line, things get complicated. This is a real issue for Python, as the The simplest fix for this would probably be to omit the shebang line when writing the temporary file on Windows (as it's already been interpreted by just). I can't think of any example where this would break anything, but it is a behaviour change, so I can understand if you had reservations. Is this something you'd consider? The alternative is probably to add a note specifically on how to work around all this for Python. But at the moment, while I have a solution that works for me, I'm not sure it works reliably for older versions of Python, and there's a risk it might fail rather drastically (creating an infinite loop running more and more processes, ultimately crashing the user's PC!) An added complication here is that the reliable solutions for the launcher use |
Ah, I didn't realize that there was another issue beyond just documenting what So the issue is that if you use |
Nor did I until I had a discussion with the Python developers 🙂
Windows doesn't parse the shebang line, the The new documentation is fine, in that it documents what's going on and the user can reason from that. So if you wanted to leave it at that, I wouldn't argue. As a practical point, though, in the same way that you have a section "Safer Bash Shebang Recipes" it might be nice to have a section "Python Shebang Recipes on Windows". I'd be willing to help write that section, but to be honest it could be skipped, and the behaviour would be much easier to understand, if you simply didn't write the shebang line to the temporary file, as I suggested. From a quick look at the source, it might be as simple as changing Footnotes
|
Okay, got it, thanks for clarifying. That makes sense, I just opened #1417, which doesn't include shebang lines on windows at all. I think this is such a minor detail that it's safe to change. In the long run, I'd like to add a recipe annotation |
I don't know why |
This is off topic, but people with multiple versions of python installed. Plus, python is not added to PATH by default (and before you say “just add it”, that has issues in a per-user install of python). |
While it might have been a bit antagonistic it was not off topic. We are discussing a fix for which there is only a single scripting language (that I know of) that requires such special consideration. And under many circumstances is not even required, if you just target
I did a quick search on it a few years ago and could find no compelling use case that effected me in the least. But did find lots of issues caused by it. Since it's been part of Python for years (a decade or more, no?) I guessed there must be some need. I've yet to hear one that is truly compelling though. But I will look into the multiple versions of Python issue again. I fully accept I may have overlooked something in the past that should have been obvious. Maybe I'll find it this time. |
Fair point. The crucial issue here is that |
I know it's an old PR sorry, but I think this page should also provide an example, I just now after reading a tail of issue seem to understand that it expects the full binary path? (talking about windows) EDIT: Oh wow even cooler, just setting the name of the binary if it's in PATH like: list-examples:
#!nu
let examples = ("{{libs}}" | lines | each {|l| ls $"libs/($l)" | get name | find examples } | flatten | each {|e| ls $e | get name} | flatten | input list)
print $examples |
@melMass shebang isn't supported on Windows natively. It is a Unix standard that all Unix variants (BSDi, Linux, macOS, etc.) supports. Casey added an emulation to make it work on Windows that doesn't actually follow the standard. But it does so in a way that I wish the standard allowed as well. In any case you don't have to specify the path. But that is only true on Windows in Just. Anywhere the path is supported natively your stuck having to use the full path or something like |
@runeimp thanks, yes and I like the idea, but to me it's not clear how to use from just the doc, I got it from reading all related issues. I would simply add an example and maybe a small line like, "either a binary in PATH or its full path" |
It seems to me that "invokes the split command and arguments" (in the windows-specific behaviour part of this chapter is fairly clear - in An extra example/comment in the docs seems like it would be fine, although it would be (IMO) quite hard to strike a balance between including something simple, and not over-complicating things by discussing all the edge cases. (To give an explicit example, "either a binary in PATH or its full path" is still incorrect, as |
Not sure what you mean I don't see a code example and it's the reason of my first comment. I did not want to start a debate, just give an insight from my perspective as a just user. |
Something like this?
That seems like a reasonable thing to add (to the windows-specific section). I've created #1709 which the maintainers can merge if they agree. |
No description provided.