So according to the docs a command written over many lines will expand to multiple parameters. This disagrees with the bash behaviour. For example
hello.lua:
local msg = "Hello, world!"
return msg
fish>
redis-cli EVAL (cat hello.lua) 0
Fails -
Whereas redis-cli EVAL "$(cat hello.lua)" 0
will succeed in bash. My question is how to prevent the (cat hello.lua)
substitution from splitting into multiple parameters due to line breaks?
fish does not have a direct analog to bash's "$(...)". The current best technique in fish is to manipulate $IFS
, which are the characters that trigger splitting. You can make it empty:
set -l IFS
redis-cli EVAL (cat hello.lua) 0
This will pass the entire contents of hello.lua
as a single argument.
Assuming you don't want your IFS changes to stick around, you can scope the change to a function, or to a block:
begin
set -l IFS
redis-cli EVAL (cat hello.lua) 0
end