Index: /trunk/src/kash/exec.c
===================================================================
--- /trunk/src/kash/exec.c	(revision 2641)
+++ /trunk/src/kash/exec.c	(revision 2642)
@@ -240,5 +240,5 @@
  */
 
-#define NEWARGS 5
+#define NEWARGS 16
 
 STATIC void
@@ -276,20 +276,16 @@
 		*ap++ = grabstackstr(psh, outp);
 	}
-	if (ap == newargs + 1) {	/* if no args, maybe no exec is needed */
-		p = newargs[0];
-		for (;;) {
-			if (equal(p, "sh") || equal(p, "ash")) {
-				TRACE((psh, "hash bang self\n"));
-				return;
-			}
-			while (*p != '/') {
-				if (*p == '\0')
-					goto break2;
-				p++;
-			}
-			p++;
-		}
-break2:;
-	}
+
+	/* if no args, maybe shell and no exec is needed. */
+	if (ap == newargs + 1) {
+		p = strrchr(newargs[0], '/');
+		if (!p)
+			p = newargs[0];
+		if (equal(p, "kmk_ash") || equal(p, "kmk_sh") || equal(p, "kash") || equal(p, "sh")) {
+			TRACE((psh, "hash bang self\n"));
+			return;
+		}
+	}
+
 	i = (char *)ap - (char *)newargs;		/* size in bytes */
 	if (i == 0)
