(no title)
rav | 1 year ago
#!/usr/bin/env -S uv run --script
causes the OS run really run env with only two arguments, namely the shebang line as one argument and the script's filename as the second argument, i.e.: /usr/bin/env '-S uv run --script' foo.py
However, the -S flag of env causes env to split everything back into separate arguments! Very cool, very useful.
sangeeth96|1 year ago
rav|1 year ago
wink|1 year ago
silverwind|1 year ago
dredmorbius|1 year ago
sudahtigabulan|1 year ago
Probably env -S is a recent addition. Or not available on all platforms they cared about.
[1]: https://www.gnu.org/software/guile/manual/html_node/The-Meta...
RHSeeger|1 year ago
- The second line is treated like a commend by the shell (and Tcl)
- The third line is executed by the shell to run Tcl with all the command line args. But then Tcl treats it as part of the second line (a comment).
Edit: Doing a bit of web searching (it's been a while since I last had the option to program in Tcl), this was also used to work around line length limitations in shebang. And also it let you exec Tcl from your path, rather than hard code it.
moondev|1 year ago
viraptor|1 year ago
__float|1 year ago
(Though, this is more general than uv for Python script deps: https://packaging.python.org/en/latest/specifications/inline...)
quotemstr|1 year ago
Ferret7446|1 year ago
oneshtein|1 year ago
MayeulC|1 year ago
So sometimes you have to resort to other tricks, such as polyglot scripts:
Or classically in Tcl: Such things are not usually needed, until they are, and they make for fun head-scratching moment. I would personally recommend against them if they can be avoided, as they are relatively fragile.I'll leave the self-compiling C language script "shebang" as an exercise to the reader ;)
IshKebab|1 year ago
gkfasdfasdf|1 year ago
mingus88|1 year ago
Oh, yet another python dependency tool. I have used a handful of them, and they keep coming
I guess no work is important enough until it gets a super fast CLI written in the language du jour and installed by piping curl into sh