From owner-freebsd-bugs@FreeBSD.ORG Fri Feb 11 22:40:19 2005 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1A33C16A4CE for ; Fri, 11 Feb 2005 22:40:19 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id D21E543D2D for ; Fri, 11 Feb 2005 22:40:18 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.1/8.13.1) with ESMTP id j1BMeIx1078493 for ; Fri, 11 Feb 2005 22:40:18 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.1/8.13.1/Submit) id j1BMeIHv078492; Fri, 11 Feb 2005 22:40:18 GMT (envelope-from gnats) Date: Fri, 11 Feb 2005 22:40:18 GMT Message-Id: <200502112240.j1BMeIHv078492@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Vsevolod Stakhov Subject: Re: bin/77259: /bin/sh: shell command "command -v cmd" doesn't work X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Vsevolod Stakhov List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Feb 2005 22:40:19 -0000 The following reply was made to PR bin/77259; it has been noted by GNATS. From: Vsevolod Stakhov 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(); + } } /*