Crawlicious | tools for web business

TAG | make

How do you change directories in a makefile, run a command and then change back? First off, all the commands that you want to run for that situation must be on the same line, because make executes each line with a new shell (weird huh?). Here is an example…

foo:
    pushd /etc; pwd; popd
    cd /bin; stat ls; cd -

Remember if you cut and paste the above code, you must change the 4 spaces preceding the line to a real tab, or make will freak out.

Either cd or pushd will work, just remember to link all your commands that belong in that same shell with a semicolon, you can also use &&, or ||, but then you need to make certain that you want the logic that implies.

Happy making!

Hide

Find it!

Theme Design by devolux.org