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.
This commit is contained in:
parent
e141581e6c
commit
beeac5cded
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=4192
11
bin/sh/cd.c
11
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;
|
||||
|
Loading…
Reference in New Issue
Block a user