Date: Fri, 11 Feb 2005 22:40:18 GMT From: Vsevolod Stakhov <vsevolod@highsecure.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/77259: /bin/sh: shell command "command -v cmd" doesn't work Message-ID: <200502112240.j1BMeIHv078492@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/77259; it has been noted by GNATS. From: Vsevolod Stakhov <vsevolod@highsecure.ru> To: freebsd-gnats-submit@FreeBSD.org, bram@vim.org Cc: Subject: Re: bin/77259: /bin/sh: shell command "command -v cmd" doesn't work Date: Sat, 12 Feb 2005 01:32:22 +0300 Here is some kind of patch: --- eval.c.orig Wed Apr 7 00:06:51 2004 +++ eval.c Sat Feb 12 01:20:11 2005 @@ -970,8 +970,10 @@ static char stdpath[] = _PATH_STDPATH; struct jmploc loc, *old; struct strlist *sp; + struct cmdentry cent; char *path; int ch; + int vcmdflag = 0; for (sp = cmdenviron; sp ; sp = sp->next) setvareq(sp->text, VEXPORT|VSTACK); @@ -979,11 +981,14 @@ optind = optreset = 1; opterr = 0; - while ((ch = getopt(argc, argv, "p")) != -1) { + while ((ch = getopt(argc, argv, "pv")) != -1) { switch (ch) { case 'p': path = stdpath; break; + case 'v': + vcmdflag = 1; + break; case '?': default: error("unknown option: -%c", optopt); @@ -993,14 +998,32 @@ argv += optind; if (argc != 0) { - old = handler; - handler = &loc; - if (setjmp(handler->loc) == 0) - shellexec(argv, environment(), path, 0); - handler = old; - if (exception == EXEXEC) - exit(exerrno); - exraise(exception); + if(!vcmdflag){ + old = handler; + handler = &loc; + if (setjmp(handler->loc) == 0) + shellexec(argv, environment(), path, 0); + handler = old; + if (exception == EXEXEC) + exit(exerrno); + exraise(exception); + } + else{ + find_command(argv[0], ¢, 0, path); + + switch(cent.cmdtype) { + case CMDNORMAL: + out1fmt("%s\n", padvance(&path, argv[0])); + break; + case CMDBUILTIN: + out1fmt("%s\n", argv[0]); + break; + default: + out1str(""); + break; + } + flushall(); + } } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200502112240.j1BMeIHv078492>