diff -pruN a/src/cmd/ksh93/sh/path.c b/src/cmd/ksh93/sh/path.c
--- a/src/cmd/ksh93/sh/path.c	2010-11-23 02:25:38.000000000 +0530
+++ b/src/cmd/ksh93/sh/path.c	2011-02-15 18:33:15.336538548 +0530
@@ -665,8 +665,9 @@ static void funload(Shell_t *shp,int fno
  * do a path search and track alias if requested
  * if flag is 0, or if name not found, then try autoloading function
  * if flag==2 or 3, returns 1 if name found on FPATH
- * if flag==3 no tracked alias will be set
+ * if flag==3 or SH_TRACKALL is not set, no tracked alias will be set
  * returns 1, if function was autoloaded.
+ * returns 2, if a tracked alias was found
  * If oldpp is not NULL, it will contain a pointer to the path component
  *    where it was found.
  */
@@ -703,7 +704,7 @@ int	path_search(Shell_t *shp,register co
 		path_init(shp);
 	if(flag)
 	{
-		if(!(flag&1) && (np=nv_search(name,shp->track_tree,0)) && !nv_isattr(np,NV_NOALIAS) && (pp=(Pathcomp_t*)np->nvalue.cp))
+		if(flag<3 && (np=nv_search(name,shp->track_tree,0)) && !nv_isattr(np,NV_NOALIAS) && (pp=(Pathcomp_t*)np->nvalue.cp))
 		{
 			stakseek(PATH_OFFSET);
 			path_nextcomp(shp,pp,name,pp);
@@ -710,7 +711,7 @@ int	path_search(Shell_t *shp,register co
 			if(oldpp)
 				*oldpp = pp;
 			stakputc(0);
-			return(0);
+			return(2);
 		}
 		pp = path_absolute(shp,name,oldpp?*oldpp:NIL(Pathcomp_t*));
 		if(oldpp)
@@ -737,7 +738,7 @@ int	path_search(Shell_t *shp,register co
 		*stakptr(PATH_OFFSET) = 0;
 		return(0);
 	}
-	else if(pp && !sh_isstate(SH_DEFPATH) && *name!='/' && flag<3)
+	else if(pp && !sh_isstate(SH_DEFPATH) && *name!='/' && flag<3 && sh_isoption(SH_TRACKALL))
 	{
 		if(np=nv_search(name,shp->track_tree,NV_ADD))
 			path_alias(np,pp);
--- a/src/cmd/ksh93/bltins/whence.c	2011-02-16 19:13:40.299538550 +0530
+++ b/src/cmd/ksh93/bltins/whence.c	2011-02-16 19:13:37.219538550 +0530
@@ -220,7 +220,8 @@ static int whence(Shell_t *shp,char **ar
 		}
 		do
 		{
-			if(path_search(shp,name,&pp,2+(aflag>1)))
+			int tracked;
+			if((tracked=path_search(shp,name,&pp,2+(aflag>1)))&1)
 				cp = name;
 			else
 			{
@@ -255,7 +256,7 @@ static int whence(Shell_t *shp,char **ar
 					if(*cp=='/' && (np=nv_search(cp,shp->bltin_tree,0)))
 						msg = sh_translate(is_builtver);
 					/* tracked aliases next */
-					else if(aflag>1 || !notrack || strchr(name,'/'))
+					else if(aflag>1 || !notrack || strchr(name,'/') || tracked!=2)
 						msg = sh_translate("is");
 					else
 						msg = sh_translate(is_talias);
diff -pruN a/src/cmd/ksh93/sh/parse.c b/src/cmd/ksh93/sh/parse.c
--- a/src/cmd/ksh93/sh/parse.c	2010-11-18 09:06:18.000000000 +0530
+++ b/src/cmd/ksh93/sh/parse.c	2011-02-16 19:27:17.595538550 +0530
@@ -1034,7 +1034,7 @@ static struct argnod *assign(Lex_t *lexp
 		{
 			struct argnod *arg = lexp->arg;
 			n = lexp->token;
-			if(path_search(lexp->sh,lexp->arg->argval,NIL(Pathcomp_t**),1) && (np=nv_search(lexp->arg->argval,lexp->sh->fun_tree,0)) && nv_isattr(np,BLT_DCL))
+			if(path_search(lexp->sh,lexp->arg->argval,NIL(Pathcomp_t**),1)&1 && (np=nv_search(lexp->arg->argval,lexp->sh->fun_tree,0)) && nv_isattr(np,BLT_DCL))
 			{
 				lexp->token = n;
 				lexp->arg = arg;
diff -pruN a/src/cmd/ksh93/sh/xec.c b/src/cmd/ksh93/sh/xec.c
--- a/src/cmd/ksh93/sh/xec.c	2011-02-09 00:38:15.000000000 +0530
+++ b/src/cmd/ksh93/sh/xec.c	2011-02-16 19:30:09.527538550 +0530
@@ -1130,7 +1130,7 @@ int sh_exec(register const Shnode_t *t, 
 				shp->lastpath = 0;
 				if(!np  && !strchr(com0,'/'))
 				{
-					if(path_search(shp,com0,NIL(Pathcomp_t**),1))
+					if(path_search(shp,com0,NIL(Pathcomp_t**),1)&1)
 					{
 						error_info.line = t->com.comline-shp->st.firstline;
 #if SHOPT_NAMESPACE
@@ -1137,7 +1137,7 @@ int sh_exec(register const Shnode_t *t, 
 						if(!shp->namespace || !(np=sh_fsearch(shp,com0,0)))
 #endif /* SHOPT_NAMESPACE */
 							np=nv_search(com0,shp->fun_tree,0);
-						if(!np && !np->nvalue.ip)
+						if(!np || !np->nvalue.ip)
 						{
 							Namval_t *mp=nv_search(com0,shp->bltin_tree,0);
 							if(mp)
