Esto se debe a que pushd es una función incorporada en bash. Por lo tanto, no está relacionada con la variable PATH y tampoco es compatible con / bin / sh (que se usa por defecto en make. Puede cambiar eso configurando SHELL (aunque no funcionará directamente (test1)).
En su lugar, puede ejecutar todos los comandos bash -c "...". Eso hará que los comandos, incluidos pushd / popd, se ejecuten en un entorno bash (test2).
SHELL = /bin/bash
test1:
@echo before
@pwd
@pushd /tmp
@echo in /tmp
@pwd
@popd
@echo after
@pwd
test2:
@/bin/bash -c "echo before;\
pwd; \
pushd /tmp; \
echo in /tmp; \
pwd; \
popd; \
echo after; \
pwd;"
Al ejecutar make test1 y make test2 da lo siguiente:
prompt>make test1
before
/download/2011/03_mar
make: pushd: Command not found
make: *** [test1] Error 127
prompt>make test2
before
/download/2011/03_mar
/tmp /download/2011/03_mar
in /tmp
/tmp
/download/2011/03_mar
after
/download/2011/03_mar
prompt>
Para test1, aunque bash se usa como shell, cada comando / línea de la regla se ejecuta por sí mismo, por lo que el comando pushd se ejecuta en un shell diferente al de popd.
pushd. ¿Está empujado en su$PATH?