问题:
在编译Makefile的时候,Makefile会使用脚本命令,调用pushd或者popd命令出现找不到的问题,错误打印如下:
/bin/sh: 1: pushd: not found
原因:
从Ubuntu 6.10开始,默认使用dash(theDebian Almquist Shell)而不是bash(the GNUBourne-Again Shell),但Login Shell还是bash,原因是dash更快、更高效,而且它符合POSIX规范,Ubuntu在启动的时候会运行很多shell脚本,使用dash可以加快启动速度。
通过如下命令确实可以看出来用的是dash。
ll /bin/sh
lrwxrwxrwx 1 root root 4 7月 5 19:32 /bin/sh -> dash*
解决方法
- 在需要bash的脚本的第一行写上"#!/bin/bash"
- 在Makefile中可以设置
SHELL = /bin/bash
- 修改默认为bash,请运行下面命令并选择no,注意这将影响所有的系统脚本执行。
sudo dpkg-reconfigure dash
参考链接:
ubuntu wiki