Reputation: 10629
I'm trying to get SBT running using the Fish shell. Below is the equivalent Bash script of what I'm trying to achieve:
java -Xmx512M -jar `dirname $0`/sbt-launch.jar "$@"
I see in the Fish documentation that $@
in Bash can be replaced with $argv
in Fish.
But I cannot see what to replace dirname $0
with.
Does anyone know the equivalent script in Fish?
Upvotes: 5
Views: 1491
Reputation: 84343
status
Builtin and argv
VariableThe fish shell uses the status
command to return information about a number of things, including the filename or directory of the currently-running script. It also uses the argv variable rather than Bash's $@
. Additionally, fish's variables are lists, so you don't want to quote them the way you do in Bash unless you're trying to treat all the contents of the list as a single string.
Assuming you're running this from a file such as foo.fish
, the way to do this would be to include the following line in your script file:
java -Xmx512M -jar (status dirname)/sbt-launch.jar $argv
Upvotes: 0
Reputation: 1846
$_ only seems to work directly via the reader/command line, or when the script is sourced, for me.
Maybe this will work for you:
java -Xmx512M -jar (dirname (status -f))/sbt-launch.jar "$argv" # fish
Upvotes: 5
Reputation: 360055
The fish
equivalent to this:
java -Xmx512M -jar $(dirname $0)/sbt-launch.jar "$@" # Bash, et al
is
java -Xmx512M -jar (dirname $_)/sbt-launch.jar "$argv" # fish
Upvotes: 1