/bin/sh:推送:找不到 [英] /bin/sh: pushd: not found

查看:223
本文介绍了/bin/sh:推送:找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作文件中做以下操作

I am doing the following inside a make file

pushd %dir_name%

我得到以下错误

/bin/sh : pushd : not found

有人可以告诉我为什么出现此错误吗? 我检查了$ PATH变量,它包含/bin,所以我认为这不会引起问题.

Can someone please tell me why this error is showing up ? I checked my $PATH variable and it contains /bin so I don't think that is causing a problem.

推荐答案

pushd是POSIX指定的Bourne Shell的bash增强. pushd不能轻易地实现为命令,因为当前工作目录是该进程的功能,子进程无法更改. (假设的pushd命令可能进行chdir(2)调用,然后启动一个新的shell,但是……它不是很有用.)pushd是一个内置的shell,只是就像cd.

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.

因此,可以将脚本更改为以#!/bin/bash开头,或者将当前工作目录存储在变量中,进行工作,然后再更改回去.取决于您是否要在非常简化的系统(例如Debian构建服务器)上运行的Shell脚本,或者是否总是需要bash.

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.

这篇关于/bin/sh:推送:找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆