- It keeps the state separate from the main shell, including $PWD (so the `cd` doesn't affect the main execution "thread")
- It executes some script in the background
Fish's backgrounding is currently limited to single external commands (not even functions). That's https://github.com/fish-shell/fish-shell/issues/238.
It also doesn't have the capability to keep $PWD separate, though other variables can of course be declared locally. That's https://github.com/fish-shell/fish-shell/issues/1439.
The workaround is, if you actually need this, to run it inside `fish -c`. Which is essentially what this syntax is doing in the background anyway (it needs to fork off because `chdir` applies to the entire process).
(Disclosure: I'm a fish developer)
If you're doing something like this in the background, then that usually means it takes a "long" time (or you'd just wait for it). So the overhead of starting an additional shell simply isn't important.
Not that it's always irrelevant, but that's why the issues are still open.
But I do often do something like:
( cd somewhere ; do_something )
just so I can avoid having to do
pushd somewhere ; do_something ; popd
(or the equivalent).
for ((i=0;i<4;++i)); do (./ad-hoc-operation >out-$i.log 2>&1 ) & done
Can be anything from image processing, video transcoding, file decompression, file system analysis - anything I think may complete faster with some concurrency.seq 0 3 | parallel "./ad-hoc-operation > out-{}.log"
Also, bash and xargs are available everywhere, on production servers as well as dev laptops. Anything that requires installing something has a big hurdle to overcome - this counts for fish too.