summaryrefslogtreecommitdiffstats
path: root/bin/sh/cd.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1994-11-06 01:29:26 +0000
committerjkh <jkh@FreeBSD.org>1994-11-06 01:29:26 +0000
commit0ba930fc76593b97ae40e4ae639d493c847a5af3 (patch)
tree151e491a5912784ef1220ba7c947d5a332bb5fc5 /bin/sh/cd.c
parent6775711bdaeefce0166aa8f60a7c1eae63914302 (diff)
downloadFreeBSD-src-0ba930fc76593b97ae40e4ae639d493c847a5af3.zip
FreeBSD-src-0ba930fc76593b97ae40e4ae639d493c847a5af3.tar.gz
Get this braindead, mongoloid shell look in /stand for pwd if it can't
find it in /bin. This is something of a kludge, I know, but consider my limited alternatives: I can't make this an execvp() without making people scream that I introduced a failure point or slowed down pwd, and I can't make it an optional macro since crunch doesn't let you pass arbitrary command-line args to the build of one of its crunch-ees. This is the simplest, if not the nicest looking, solution I could come up with.
Diffstat (limited to 'bin/sh/cd.c')
-rw-r--r--bin/sh/cd.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/bin/sh/cd.c b/bin/sh/cd.c
index b81199e..29bc1fd 100644
--- a/bin/sh/cd.c
+++ b/bin/sh/cd.c
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id$
+ * $Id: cd.c,v 1.2 1994/09/24 02:57:24 davidg Exp $
*/
#ifndef lint
@@ -55,6 +55,7 @@ static char sccsid[] = "@(#)cd.c 8.1 (Berkeley) 5/31/93";
#include "mystring.h"
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/unistd.h>
#include <errno.h>
@@ -336,12 +337,16 @@ getpwd() {
int status;
struct job *jp;
int pip[2];
+ char *pwd_bin = "/bin/pwd";
if (curdir)
return;
INTOFF;
if (pipe(pip) < 0)
error("Pipe call failed");
+ /* make a fall-back guess, otherwise we're simply screwed */
+ if (access(pwd_bin, X_OK) == -1)
+ pwd_bin = "/stand/pwd";
jp = makejob((union node *)NULL, 1);
if (forkshell(jp, (union node *)NULL, FORK_NOJOB) == 0) {
close(pip[0]);
@@ -350,8 +355,8 @@ getpwd() {
copyfd(pip[1], 1);
close(pip[1]);
}
- execl("/bin/pwd", "pwd", (char *)0);
- error("Cannot exec /bin/pwd");
+ execl(pwd_bin, "pwd", (char *)0);
+ error("Cannot exec %s", pwd_bin);
}
close(pip[1]);
pip[1] = -1;
OpenPOWER on IntegriCloud