/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley Software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "sh.h"
#include "sh.tconst.h"
/*
* C shell
*/
/*
* Determine if file given by name is accessible with permissions
* given by mode.
*
* Borrowed from the Bourne sh, and modified a bit
*
* If the requested access is permitted, a value of 0 is
* returned. Otherwise, a value of -1 is returned and errno is
* set to indicate the error
*/
int
{
static int flag;
/* convert tchar * to char * */
if (flag == 0) {
flag = 1;
}
if (euid == 0) {
return (0);
/* root can execute file as long as it has execute
permission for someone */
return (0);
return (-1);
}
return (0);
}
}
return (-1);
}
int
{
#ifdef TRACE
tprintf("TRACE- exp()\n");
#endif
}
int
{
#ifdef TRACE
tprintf("TRACE- exp0()\n");
#endif
#ifdef EDEBUG
#endif
int p2;
(*vp)++;
#ifdef EDEBUG
#endif
}
return (p1);
}
int
{
#ifdef TRACE
tprintf("TRACE- exp1()\n");
#endif
#ifdef EDEBUG
#endif
int p2;
(*vp)++;
#ifdef EDEBUG
#endif
}
return (p1);
}
int
{
#ifdef TRACE
tprintf("TRACE- exp2()\n");
#endif
#ifdef EDEBUG
#endif
int p2;
(*vp)++;
#ifdef EDEBUG
#endif
}
return (p1);
}
int
{
#ifdef TRACE
tprintf("TRACE- exp2a()\n");
#endif
#ifdef EDEBUG
#endif
int p2;
(*vp)++;
#ifdef EDEBUG
#endif
}
return (p1);
}
int
{
#ifdef TRACE
tprintf("TRACE- exp2b()\n");
#endif
#ifdef EDEBUG
#endif
int p2;
(*vp)++;
#ifdef EDEBUG
#endif
}
return (p1);
}
int
{
int i;
#ifdef TRACE
tprintf("TRACE- exp2c()\n");
#endif
#ifdef EDEBUG
#endif
(*vp)++;
if (i == EQMATCH || i == NOTEQMATCH)
#ifdef EDEBUG
#endif
case EQEQ:
break;
case NOTEQ:
break;
case EQMATCH:
break;
case NOTEQMATCH:
break;
}
return (i);
}
return (i);
}
tchar *
{
int i;
#ifdef TRACE
tprintf("TRACE- exp3()\n");
#endif
#ifdef EDEBUG
#endif
(*vp)++;
i |= 1, (*vp)++;
#ifdef EDEBUG
#endif
case GTR:
break;
case GTR|1:
break;
case LSS:
break;
case LSS|1:
break;
}
return (putn(i));
}
return (p1);
}
tchar *
{
int i;
#ifdef TRACE
tprintf("TRACE- exp3a()\n");
#endif
#ifdef EDEBUG
#endif
/* if (op && any(op[0], "<>") && op[0] == op[1]) { */
(*vp)++;
#ifdef EDEBUG
#endif
if (op[0] == '<')
else
return (putn(i));
}
return (p1);
}
tchar *
{
int i = 0;
#ifdef TRACE
tprintf("TRACE- exp4()\n");
#endif
#ifdef EDEBUG
#endif
#ifdef EDEBUG
#endif
case '+':
break;
case '-':
break;
}
return (putn(i));
}
return (p1);
}
tchar *
{
int i = 0;
#ifdef TRACE
tprintf("TRACE- exp5()\n");
#endif
#ifdef EDEBUG
#endif
#ifdef EDEBUG
#endif
case '*':
break;
case '/':
if (i == 0)
error("Divide by 0");
break;
case '%':
if (i == 0)
error("Mod by 0");
break;
}
return (putn(i));
}
return (p1);
}
tchar *
{
int ccode, i;
#ifdef TRACE
tprintf("TRACE- exp6()\n");
#endif
if (**vp == 0)
bferr("Expression syntax");
(*vp)++;
#ifdef EDEBUG
#endif
return (putn(!i));
}
(*vp)++;
#ifdef EDEBUG
#endif
return (putn(~i));
}
(*vp)++;
#ifdef EDEBUG
#endif
bferr("Expression syntax");
(*vp)++;
}
tchar **v;
(*vp)++;
v = *vp;
for (;;) {
if (!**vp)
bferr("Missing }");
break;
}
return (S_ /* "" */);
psavejob();
*--(*vp) = 0;
evalav(v);
exitstat();
}
pwait();
prestjob();
#ifdef EDEBUG
#endif
}
return (S_ /* "" */);
bferr("Malformed file inquiry");
/*
* Detect missing file names by checking for operator
* in the file name position. However, if an operator
* name appears there, we must make sure that there's
* no file by that name (e.g., "/") before announcing
* an error. Even this check isn't quite right, since
* it doesn't take globbing into account.
*/
bferr("Missing file name");
return (S_ /* "" */);
switch (cp[1]) {
case 'r':
break;
case 'w':
break;
case 'x':
break;
default:
return (S_0 /* "0" */);
}
switch (cp[1]) {
case 'f':
break;
case 'd':
break;
case 'z':
break;
case 'e':
i = 1;
break;
case 'o':
break;
}
}
#ifdef EDEBUG
#endif
return (putn(i));
}
#ifdef EDEBUG
#endif
}
void
{
struct command *t;
#ifdef TRACE
tprintf("TRACE- evalav()\n");
#endif
while (*v) {
}
if (err)
execute(t, -1);
}
int
{
#ifdef TRACE
tprintf("TRACE- isa()\n");
#endif
if (cp == 0)
if (cp[1] == 0) {
return (1);
return (1);
return (1);
} else if (cp[2] == 0) {
return (1);
return (1);
return (1);
}
if (cp[0] == '=') {
return (EQEQ);
return (EQMATCH);
} else if (cp[0] == '!') {
return (NOTEQ);
return (NOTEQMATCH);
}
}
}
if (*cp == '<')
return (LSS);
if (*cp == '>')
return (GTR);
}
return (0);
}
int
{
#ifdef TRACE
tprintf("TRACE- egetn()\n");
#endif
bferr("Expression syntax");
}
/* Phew! */
#ifdef EDEBUG
void
{
printf("\n");
}
void
{
printf("\n");
}
#endif