2

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?

0

1 Answer 1

3

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
2
  • Thanks for taking the time to respond. Since Fish aims to be a more practical shell at the cost of some standard compliance, is there a chance we might ever see argument splitting/joining with a built-in function or symbol? These things are very painful Commented Jul 19, 2015 at 14:38
  • Yes, there's an old proposal of mine, and a separate proposal for a string builtin that will support splitting and joining is being actively worked on too. Commented Jul 20, 2015 at 18:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.