Just started playing with fish shell today and was trying to translate a Bash function. It works but I was wondering if there was a more elegant way to pass all parameters in fish.
Bash function to run Elixir command in Docker container:
function elixir () {
docker run --rm -it -v $(pwd):/app -w /app elixir \
sh -ci "elixir $*"
}
fish function:
function elixir --description "command to run Elixir in Docker"
docker run --rm -it -v (pwd):/app -w /app elixir elixir $argv[1..-1]
end
Thanks!
In fish all variables are lists, and $var
expands to the entire list, one argument per element (so there's no word splitting or anything).
So just $argv
is enough, there is no need to specify [1..-1]
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With