/bin/sh: pushd: not found

前端 未结 11 651
借酒劲吻你
借酒劲吻你 2020-12-13 11:31

I am doing the following inside a make file

pushd %dir_name%

and i get the following error

/bin/sh : pushd : not foun         


        
11条回答
  •  伪装坚强ぢ
    2020-12-13 12:30

    Synthesizing from the other responses: pushd is bash-specific and you are make is using another POSIX shell. There is a simple workaround to use separate shell for the part that needs different directory, so just try changing it to:

    test -z gen || mkdir -p gen \
     && ( cd $(CURRENT_DIRECTORY)/genscript > /dev/null \
     && perl genmakefile.pl \
     && mv Makefile ../gen/ ) \
     && echo "" > $(CURRENT_DIRECTORY)/gen/SvcGenLog
    

    (I substituted the long path with a variable expansion. I probably is one in the makefile and it clearly expands to the current directory).

    Since you are running it from make, I would probably replace the test with a make rule, too. Just

    gen/SvcGenLog :
        mkdir -p gen
        cd genscript > /dev/null \
         && perl genmakefile.pl \
         && mv Makefile ../gen/ \
        echo "" > gen/SvcGenLog
    

    (dropped the current directory prefix; you were using relative path at some points anyway) And than just make the rule depend on gen/SvcGenLog. It would be a bit more readable and you can make it depend on the genscript/genmakefile.pl too, so the Makefile in gen will be regenerated if you modify the script. Of course if anything else affects the content of the Makefile, you can make the rule depend on that too.

提交回复
热议问题