我在bashrc中添加了以下函数:
function cd(){
echo "user switching to" $1
cd $1
}在重新加载.bashrc之后,尝试在临时目录(任何目录)中尝试cd会出现以下递归错误:-
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/
bash: echo: write error: Bad address
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/
user switching to temp/当用户使用cd命令时,我希望方法名是cd,因为我希望执行一些逻辑。
发布于 2017-05-13 20:40:26
您可以在bash中使用builtin命令:
function cd(){
echo "user switching to $1"
builtin cd "$@"
}https://stackoverflow.com/questions/43957758
复制相似问题