/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2011 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* command [-pvVx] name [arg...]
* whence [-afvp] name...
*
* David Korn
* AT&T Labs
*
*/
#include "defs.h"
#include <error.h>
#include "shtable.h"
#include "name.h"
#include "path.h"
#include "shlex.h"
#include "builtins.h"
/*
* command is called with argc==0 when checking for -V or -v option
* In this case return 0 when -v or -V or unknown option, otherwise
* the shift count to the command is returned
*/
{
register int n, flags=0;
{
case 'p':
if(sh_isoption(SH_RESTRICTED))
break;
case 'v':
break;
case 'V':
break;
case 'x':
break;
case ':':
if(argc==0)
return(0);
break;
case '?':
if(argc==0)
return(0);
break;
}
if(argc==0)
}
/*
* for the whence command
*/
{
register int flags=0, n;
if(*argv[0]=='t')
{
case 'a':
/* FALL THRU */
case 'v':
break;
case 'f':
break;
case 'p':
break;
case 'q':
break;
case ':':
break;
case '?':
break;
}
}
{
register const char *name;
register const char *cp;
register int aflag,r=0;
register const char *msg;
int tofree;
char *notused;
{
tofree=0;
cp = 0;
np = 0;
goto search;
goto bltins;
/* reserved words first */
{
if(!aflag)
continue;
aflag++;
}
/* non-tracked aliases */
{
{
else
}
if(!aflag)
continue;
cp = 0;
aflag++;
}
/* built-ins and functions next */
{
goto search;
cp = "";
{
else if(is_abuiltin(np))
{
else
}
else
}
continue;
if(!aflag)
continue;
cp = 0;
aflag++;
}
if(sh_isstate(SH_DEFPATH))
{
cp=0;
notrack=1;
}
do
{
else
{
if(*cp==0)
cp = 0;
else if(*cp!='/')
{
tofree=1;
}
}
{
pp = 0;
r |= !cp;
}
else if(cp)
{
{
if(*cp!= '/')
{
continue;
}
/* built-in version of program */
/* tracked aliases next */
else
}
if(aflag)
{
if(aflag<=1)
aflag++;
if (pp)
}
else
pp = 0;
if(tofree)
}
else if(aflag<=1)
{
r |= 1;
}
} while(pp);
}
return(r);
}