In Unix, can I run 'make' in a directory without cd'ing to that directory first?

后端 未结 5 1117
后悔当初
后悔当初 2021-01-29 18:42

In Unix, can I run make in a directory without cd\'ing to that directory first?

5条回答
  •  长发绾君心
    2021-01-29 19:03

    If the reason you don't want to cd to a directory is because you need to stay in the current directory for a later task, you can use pushd and popd:

    pushd ProjectDir ; make ; popd
    

    That goes into the ProjectDir, runs make, and goes back to where you were.

提交回复
热议问题