I'd like to always run a fish script in the background even if the user doesn't specify that.
In bash, this can be done by surrounding the script with (
at the start and ) &
at the end.
Is there anyway for a fish script to run itself in the background?
command &
, the$(command) &
syntax you describe is something else (and makes little sense). – terdon Jun 19 '16 at 18:34foo.fish
, then I intended for the script to run in the background when the user executes./foo.fish
. Surrounding multiple lines with()
runs them in a subshell and&
runs them in the background. Anyway, feel free to ignore this question as I've found out that it's not possible: https://github.com/fish-shell/fish-shell/issues/238 – user175817 Jun 19 '16 at 18:38./foo.fish &
. The post you linked to is about sending functions to the background. We might be able to help you but you need to give us a specific example. – terdon Jun 19 '16 at 18:43./foo.fish &
. So even if the user runs./foo.fish
, the script should run in the background. The reason is because the script is invoked from an openvpn config file with the lineipchange foo.fish
which doesn't support any arguments and cannot use&
. – user175817 Jun 19 '16 at 18:51foo.fish
) and one,bar.sh
, that calls it as a background process:foo.fish &
. You then have your user runbar.sh
instead offoo.fish
. – terdon Jun 19 '16 at 18:53