5 ms·
Why is the ‘-S’ argument to ‘env’ needed? Based on the man page it doesn’t appear to be doing anything useful here, and in practice it doesn’t either.
by moleperson 11mo ago
Why is the ‘-S’ argument to ‘env’ needed? Based on the man page it doesn’t appear to be doing anything useful here, and in practice it doesn’t either.
- zahlman 11mo ago> Based on the man page it doesn’t appear to be doing anything useful here The man page tells me: -S, --split-string=S process and split S into separate arguments; used to pass multi‐ ple arguments on shebang lines Without that, the system may try to treat the entirety of "uv run --script" as the program name, and fail to find it. Depending on your env implementation and/or your shell, this may not be needed. See also: https://unix.stackexchange.com/questions/361794 https://unix.stackexchange.com/questions/361794
- moleperson 11mo agoRight, I didn’t think about the shebang case being different. Thanks!
- Rogach 11mo agoWithout -S, `uv run --script` would be treated as a binary name (including spaces) and you will get an error like "env: ‘uv run --script’: No such file or directory". -S causes the string to be split on spaces and so the arguments are passed correctly.
- gcr 11mo agoOn these systems, wouldn’t binfmt attempt to exec(“/usr/bin/env -S uv run --script”, “foo.py”) and fail anyway for the same reason?
- pseudalopex 11mo agoMost systems split at least the 1st space since decades.
- deleted 11mo ago[deleted]
- Rogach 11mo agoNo. The string is split to extract at most one argument. See: https://linux.die.net/man/2/execve https://linux.die.net/man/2/execve So in fact "-S" is not passed as a separate argument, but as a prefix in the first (and only) argument, and env then extracts it and acts accordingly: ``` $ /usr/bin/env "-S echo deadbeef" deadbeef ```