/bin/sh: pushd: not found

前端 未结 11 654
借酒劲吻你
借酒劲吻你 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:09

    pushd is a bash enhancement to the POSIX-specified Bourne Shell. pushd cannot be easily implemented as a command, because the current working directory is a feature of a process that cannot be changed by child processes. (A hypothetical pushd command might do the chdir(2) call and then start a new shell, but ... it wouldn't be very usable.) pushd is a shell builtin, just like cd.

    So, either change your script to start with #!/bin/bash or store the current working directory in a variable, do your work, then change back. Depends if you want a shell script that works on very reduced systems (say, a Debian build server) or if you're fine always requiring bash.

提交回复
热议问题