From beeac5cded5656f51522a3753af09f69bc17c9fa Mon Sep 17 00:00:00 2001 From: "Jordan K. Hubbard" Date: Sun, 6 Nov 1994 01:29:26 +0000 Subject: [PATCH] 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. --- bin/sh/cd.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/sh/cd.c b/bin/sh/cd.c index b81199e0feb..29bc1fdc726 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 #include +#include #include @@ -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;