example.sh
#!/bin/bash
echo "Hello world!"
If we want to execute this script from Fish Shell, we can use either exec
or eval
exec bash example.sh
Fish Shell replaces itself with the new process - the Bash interpreter running example.sh
script. This means that when the script finishes, the Bash interpreter takes over the terminal and Fish Shell is no longer running!
eval bash example.sh
Fish Shell stays running, but the output of the command is printed to the terminal as usual. This means that after the script finishes, Fish Shell is still running and we can continue to use it.