scala-cli
scala-cli copied to clipboard
Document how to use `shebang` in environments where `env -S` is not available
Version(s) Latest one
Describe the bug I'm writing a script for Amazon Linux. Here is how the script starts:
#!/usr/bin/env -S scala-cli shebang
The problem is that env doesn't have the -S option
In Ubuntu that option does exists, but in Amazon Linux (Red Hat based) doesn't:
NAME
env - run a program in a modified environment
SYNOPSIS
env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]
DESCRIPTION
Set each NAME to VALUE in the environment and run COMMAND.
Mandatory arguments to long options are mandatory for short options too.
-i, --ignore-environment
start with an empty environment
-0, --null
end each output line with 0 byte rather than newline
-u, --unset=NAME
remove variable from the environment
--help display this help and exit
To Reproduce Run a script
Expected behaviour Scripts are easy to write.
Only workaround I can think of, is to create an auxiliary script like:
$cat scala-cli2
exec scala-cli shebang "$@"
What I've done as a workaround is install GNU env in /usr/local/bin and then reference it from my shebang line.
Another workaround would be to hardcode the location of scala-cli in the shebang line. (If the full path is unwieldy, a symbolic link can be made from /usr/local/bin or wherever to the real path.)
I think this is not a bug in scala-cli, but perhaps the documentation could say something about it.
I think this is not a bug in scala-cli, but perhaps the documentation could say something about it.
I agree on this. We should add a section about it in the shebang sub-command and scripts-related docs. Not much else that we can do with this on Scala CLI side, I think.
With Ammonite scripts, I haven't experienced this problem, as I don't need to pass any special arguments.