I use this command to make
inside a folder:
cd build/ && make
But I want to return to original directory after the command
I tried this:
cd build/ && make && cd ..
But this doesn’t work. How can I do it? Would help in quick testing…
Advertisement
Answer
Use a subshell, like so:
$ pwd /tmp $ (cd build && make) $ pwd /tmp
The shell forks before running the commands in brackets, so once it completes it’s as if you never left the current directory.