This is the mail archive of the cygwin-apps@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Minor /bin/sh bug


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
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 <sys/types.h>
@@ -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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]