From Simon Willison. There is always the possibility of cd
ing into a directory and returning afterwards:
cd some-dir && ./my-script && cd -
Another way would be to use push
and popd
:
pushd some-dir && ./my-script && popd
However you can run commands like the this in a subshell, using parenthesis:
(cd some-dir && ./my-script)