Mailing-List: contact cygwin-apps-help AT sourceware DOT cygnus DOT com; run by ezmlm list-help: list-post: Sender: cygwin-apps-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-apps AT sourceware DOT cygnus DOT com Sender: corinna AT snoopy DOT vinschen DOT de Message-ID: <393EC63D.4692216F@vinschen.de> Date: Thu, 08 Jun 2000 00:01:33 +0200 From: Corinna Vinschen Reply-To: cygwin Organization: Cygnus Solutions, a Red Hat company X-Mailer: Mozilla 4.73 [en] (X11; I; Linux 2.2.14 i686) X-Accept-Language: de, en MIME-Version: 1.0 To: Paul Stodghill CC: cygwin , cygapp Subject: Re: Minor /bin/sh bug References: Content-Type: multipart/mixed; boundary="------------19121040FC581B2A54D3680E" This is a multi-part message in MIME format. --------------19121040FC581B2A54D3680E Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Paul Stodghill wrote: > > I believe that I am running the latest version of everything, including the > 6/1 snapshot > > The bug is that the "type" command returns the wrong file name when given an > absolute pathname. > > milhouse% sh -c 'type /bin/ls' > /bin/ls is /home/stodghil/bib/bin//bin/ls > milhouse% bash -c 'type /bin/ls' > /bin/ls is /bin/ls > milhouse% > > By the way, which shell is /bin/sh based on? It's ash. I have just patched ash to get rid of that problem. I have attached the patch. It will go into the release later. Corinna -- Corinna Vinschen Cygwin Developer Cygnus Solutions, a Red Hat company --------------19121040FC581B2A54D3680E Content-Type: text/plain; charset=us-ascii; name="type.p0" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="type.p0" Index: exec.c =================================================================== RCS file: /cvs/cvsfiles/devo/ash/exec.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -p -r1.6 -r1.7 --- exec.c 2000/05/08 01:59:39 1.6 +++ exec.c 2000/06/07 20:40:55 1.7 @@ -39,7 +39,7 @@ static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95"; #endif static const char rcsid[] = - "$Id: exec.c,v 1.6 2000/05/08 01:59:39 vinschen Exp $"; + "$Id: exec.c,v 1.7 2000/06/07 20:40:55 vinschen Exp $"; #endif /* not lint */ #include @@ -445,8 +445,13 @@ find_command(name, entry, printerr, path /* If name contains a slash, don't use the hash table */ if (strchr(name, '/') != NULL) { - entry->cmdtype = CMDNORMAL; - entry->u.index = 0; + if (stat(name, &statb) == 0 && + S_ISREG(statb.st_mode) && + (statb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))) + entry->cmdtype = CMDNORMAL; + else + entry->cmdtype = CMDUNKNOWN; + entry->u.index = -1; return; } @@ -908,10 +913,13 @@ typecmd(argc, argv) case CMDNORMAL: { int j = entry.u.index; char *path = pathval(), *name; - do { - name = padvance(&path, argv[i]); - stunalloc(name); - } while (--j >= 0); + if (j == -1) + name = argv[i]; + else + do { + name = padvance(&path, argv[i]); + stunalloc(name); + } while (--j >= 0); out1fmt(" is%s %s\n", cmdp ? " a tracked alias for" : "", name); break; --------------19121040FC581B2A54D3680E--