I use the fish shell and would like to be able to "source" some shell scripts written with sh-compatible syntax, which fish cannot read. For example lots of software expects you to source some shell scripts to export helpful environment variables:
# customvars.sh
FOOBAR=qwerty
export FOOBAR
If I don't care about preserving local variable and function definitions, one workaround is to use exec to replace the current process with /bin/sh and then go back to fish
# We start out on fish
exec /bin/sh
# Running a POSIX shell now
. customvars.sh
exec /usr/bin/fish
# Back on fish
echo $FOOBAR
Is there a way to boil this pattern down to an one-liner that I can save in a function somewhere? If I try doing
exec /bin/sh -c '. vars.sh; /usr/bin/fish'
my terminal emulator window closes immediately instead of taking me back to an interactive fish prompt.