I have a rather long bash script for setting up a server cluster. I'd like to start switching over to fish interpreter but I'd like to do it in steps. Can I keep my bash script as is and add the fish
command to switch to fish prompt and the rest of the bash script will execute the rest of the commands from the fish interpreter, even though it's a #!/bin/bash
script?
If you're thinking you might be able to do this:
then no, it doesn't work like that. That would start an interactive fish session in the middle of the script, and when you exit from that fish process, bash would attempt to execute the rest of the commands as bash commands. You'd clearly see syntax error messages.
You would have to do
fish -c 'fish commands ...'
, but that can easily lead to quoting hell. The safest way to mix languages in a bash script is to use a quoted heredoc. You can expose bash variables for the fish part by using the environment.