bin/77259: /bin/sh: shell command "command -v cmd" doesn't work
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Feb 11 14:40:19 PST 2005
The following reply was made to PR bin/77259; it has been noted by GNATS.
From: Vsevolod Stakhov <vsevolod at highsecure.ru>
To: freebsd-gnats-submit at FreeBSD.org, bram at 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();
+ }
}
/*
More information about the freebsd-bugs
mailing list