#include <time.h>
#include <fnmatch.h>
-#ifdef CONFIG_ASH_JOB_CONTROL
+#if ENABLE_ASH_JOB_CONTROL
#define JOBS 1
#else
#define JOBS 0
#endif
-#if JOBS || defined(CONFIG_ASH_READ_NCHARS)
+#if JOBS || ENABLE_ASH_READ_NCHARS
#include <termios.h>
#endif
#endif
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
/* alias.h */
#define ALIASINUSE 1
static void sh_warnx(const char *, ...);
-#ifdef CONFIG_ASH_OPTIMIZE_FOR_SIZE
+#if ENABLE_ASH_OPTIMIZE_FOR_SIZE
static void
inton(void) {
if (--suppressint == 0 && intpending) {
if (intpending) onint(); \
0; \
})
-#endif /* CONFIG_ASH_OPTIMIZE_FOR_SIZE */
+#endif /* ASH_OPTIMIZE_FOR_SIZE */
/* expand.h */
static char *_rmescapes(char *, int);
static int casematch(union node *, char *);
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
static void expari(int);
#endif
#define NNOT 25
-
struct ncmd {
int type;
union node *assign;
union node *redirect;
};
-
struct npipe {
int type;
int backgnd;
struct nodelist *cmdlist;
};
-
struct nredir {
int type;
union node *n;
union node *redirect;
};
-
struct nbinary {
int type;
union node *ch1;
union node *ch2;
};
-
struct nif {
int type;
union node *test;
union node *elsepart;
};
-
struct nfor {
int type;
union node *args;
char *var;
};
-
struct ncase {
int type;
union node *expr;
union node *cases;
};
-
struct nclist {
int type;
union node *next;
union node *body;
};
-
struct narg {
int type;
union node *next;
struct nodelist *backquote;
};
-
struct nfile {
int type;
union node *next;
char *expfname;
};
-
struct ndup {
int type;
union node *next;
union node *vname;
};
-
struct nhere {
int type;
union node *next;
union node *doc;
};
-
struct nnot {
int type;
union node *com;
};
-
union node {
int type;
struct ncmd ncmd;
struct nnot nnot;
};
-
struct nodelist {
struct nodelist *next;
union node *n;
};
-
struct funcnode {
int count;
union node n;
struct strpush *prev; /* preceding string on stack */
char *prevstring;
int prevnleft;
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
struct alias *ap; /* if push was associated with an alias */
#endif
char *string; /* remember the string since it may change */
#define CSPCL 13 /* these terminate a word */
#define CIGN 14 /* character should be ignored */
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
#define SYNBASE 130
#define PEOF -130
#define PEOA -129
* This file was generated by the mksyntax program.
*/
-#ifdef CONFIG_ASH_OPTIMIZE_FOR_SIZE
+#if ENABLE_ASH_OPTIMIZE_FOR_SIZE
#define USE_SIT_FUNCTION
#endif
#define SQSYNTAX 2 /* in single quotes */
#define ARISYNTAX 3 /* in arithmetic */
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
static const char S_I_T[][4] = {
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
{CSPCL, CIGN, CIGN, CIGN}, /* 0, PEOA */
#endif
{CSPCL, CWORD, CWORD, CWORD}, /* 1, ' ' */
};
#else
static const char S_I_T[][3] = {
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
{CSPCL, CIGN, CIGN}, /* 0, PEOA */
#endif
{CSPCL, CWORD, CWORD}, /* 1, ' ' */
{CCTL, CCTL, CCTL} /* 14, CTLESC ... */
#endif
};
-#endif /* CONFIG_ASH_MATH_SUPPORT */
+#endif /* ASH_MATH_SUPPORT */
#ifdef USE_SIT_FUNCTION
static int SIT(int c, int syntax)
{
static const char spec_symbls[] = "\t\n !\"$&'()*-/:;<=>?[\\]`|}~";
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
static const char syntax_index_table[] = {
1, 2, 1, 3, 4, 5, 1, 6, /* "\t\n !\"$&'" */
7, 8, 3, 3, 3, 3, 1, 1, /* "()*-/:;<" */
if (c == PEOF) /* 2^8+2 */
return CENDFILE;
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
if (c == PEOA) /* 2^8+1 */
indx = 0;
else
#define SIT(c, syntax) S_I_T[(int)syntax_index_table[((int)c)+SYNBASE]][syntax]
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
#define CSPCL_CIGN_CIGN_CIGN 0
#define CSPCL_CWORD_CWORD_CWORD 1
#define CNL_CNL_CNL_CNL 2
static const char syntax_index_table[258] = {
/* BASESYNTAX_DQSYNTAX_SQSYNTAX_ARISYNTAX */
/* 0 PEOF */ CENDFILE_CENDFILE_CENDFILE_CENDFILE,
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
/* 1 PEOA */ CSPCL_CIGN_CIGN_CIGN,
#endif
/* 2 -128 0x80 */ CWORD_CWORD_CWORD_CWORD,
#endif
static int breakcmd(int, char **);
static int cdcmd(int, char **);
-#ifdef CONFIG_ASH_CMDCMD
+#if ENABLE_ASH_CMDCMD
static int commandcmd(int, char **);
#endif
static int dotcmd(int, char **);
static int evalcmd(int, char **);
-#ifdef CONFIG_ASH_BUILTIN_ECHO
+#if ENABLE_ASH_BUILTIN_ECHO
static int echocmd(int, char **);
#endif
-#ifdef CONFIG_ASH_BUILTIN_TEST
+#if ENABLE_ASH_BUILTIN_TEST
static int testcmd(int, char **);
#endif
static int execcmd(int, char **);
#if JOBS
static int fgcmd(int, char **);
#endif
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
static int getoptscmd(int, char **);
#endif
static int hashcmd(int, char **);
#if JOBS
static int jobscmd(int, char **);
#endif
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
static int letcmd(int, char **);
#endif
static int localcmd(int, char **);
/* mail.h */
-#ifdef CONFIG_ASH_MAIL
+#if ENABLE_ASH_MAIL
static void chkmail(void);
static void changemail(const char *);
#endif
static const struct builtincmd builtincmd[] = {
{ BUILTIN_SPEC_REG ".", dotcmd },
{ BUILTIN_SPEC_REG ":", truecmd },
-#ifdef CONFIG_ASH_BUILTIN_TEST
+#if ENABLE_ASH_BUILTIN_TEST
{ BUILTIN_REGULAR "[", testcmd },
{ BUILTIN_REGULAR "[[", testcmd },
#endif
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
{ BUILTIN_REG_ASSG "alias", aliascmd },
#endif
#if JOBS
{ BUILTIN_SPEC_REG "break", breakcmd },
{ BUILTIN_REGULAR "cd", cdcmd },
{ BUILTIN_NOSPEC "chdir", cdcmd },
-#ifdef CONFIG_ASH_CMDCMD
+#if ENABLE_ASH_CMDCMD
{ BUILTIN_REGULAR "command", commandcmd },
#endif
{ BUILTIN_SPEC_REG "continue", breakcmd },
-#ifdef CONFIG_ASH_BUILTIN_ECHO
+#if ENABLE_ASH_BUILTIN_ECHO
{ BUILTIN_REGULAR "echo", echocmd },
#endif
{ BUILTIN_SPEC_REG "eval", evalcmd },
#if JOBS
{ BUILTIN_REGULAR "fg", fgcmd },
#endif
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
{ BUILTIN_REGULAR "getopts", getoptscmd },
#endif
{ BUILTIN_NOSPEC "hash", hashcmd },
{ BUILTIN_REGULAR "jobs", jobscmd },
{ BUILTIN_REGULAR "kill", killcmd },
#endif
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
{ BUILTIN_NOSPEC "let", letcmd },
#endif
{ BUILTIN_ASSIGN "local", localcmd },
{ BUILTIN_SPEC_REG "set", setcmd },
{ BUILTIN_SPEC_REG "shift", shiftcmd },
{ BUILTIN_SPEC_REG "source", dotcmd },
-#ifdef CONFIG_ASH_BUILTIN_TEST
+#if ENABLE_ASH_BUILTIN_TEST
{ BUILTIN_REGULAR "test", testcmd },
#endif
{ BUILTIN_SPEC_REG "times", timescmd },
{ BUILTIN_NOSPEC "type", typecmd },
{ BUILTIN_NOSPEC "ulimit", ulimitcmd },
{ BUILTIN_REGULAR "umask", umaskcmd },
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
{ BUILTIN_REGULAR "unalias", unaliascmd },
#endif
{ BUILTIN_SPEC_REG "unset", unsetcmd },
static void defun(char *, union node *);
static void unsetfunc(const char *);
-#ifdef CONFIG_ASH_MATH_SUPPORT_64
+#if ENABLE_ASH_MATH_SUPPORT_64
typedef int64_t arith_t;
#define arith_t_type (long long)
#else
#define arith_t_type (long)
#endif
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
static arith_t dash_arith(const char *);
static arith_t arith(const char *expr, int *perrcode);
#endif
-#ifdef CONFIG_ASH_RANDOM_SUPPORT
+#if ENABLE_ASH_RANDOM_SUPPORT
static unsigned long rseed;
static void change_random(const char *);
# ifndef DYNAMIC_VAR
* Shell variables.
*/
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
static void getoptsreset(const char *);
#endif
-#ifdef CONFIG_LOCALE_SUPPORT
+#if ENABLE_LOCALE_SUPPORT
static void change_lc_all(const char *value);
static void change_lc_ctype(const char *value);
#endif
{ 0, VSTRFIXED|VTEXTFIXED|VUNSET, "IFS\0", 0 },
#endif
-#ifdef CONFIG_ASH_MAIL
+#if ENABLE_ASH_MAIL
{ 0, VSTRFIXED|VTEXTFIXED|VUNSET, "MAIL\0", changemail },
{ 0, VSTRFIXED|VTEXTFIXED|VUNSET, "MAILPATH\0", changemail },
#endif
{ 0, VSTRFIXED|VTEXTFIXED, "PS1=$ ", 0 },
{ 0, VSTRFIXED|VTEXTFIXED, "PS2=> ", 0 },
{ 0, VSTRFIXED|VTEXTFIXED, "PS4=+ ", 0 },
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
{ 0, VSTRFIXED|VTEXTFIXED, "OPTIND=1", getoptsreset },
#endif
-#ifdef CONFIG_ASH_RANDOM_SUPPORT
+#if ENABLE_ASH_RANDOM_SUPPORT
{0, VSTRFIXED|VTEXTFIXED|VUNSET|VDYNAMIC, "RANDOM\0", change_random },
#endif
-#ifdef CONFIG_LOCALE_SUPPORT
+#if ENABLE_LOCALE_SUPPORT
{0, VSTRFIXED | VTEXTFIXED | VUNSET, "LC_ALL\0", change_lc_all },
{0, VSTRFIXED | VTEXTFIXED | VUNSET, "LC_CTYPE\0", change_lc_ctype },
#endif
};
#define vifs varinit[0]
-#ifdef CONFIG_ASH_MAIL
+#if ENABLE_ASH_MAIL
#define vmail (&vifs)[1]
#define vmpath (&vmail)[1]
#else
#define vps2 (&vps1)[1]
#define vps4 (&vps2)[1]
#define voptind (&vps4)[1]
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
#define vrandom (&voptind)[1]
#else
#define vrandom (&vps4)[1]
static int showvars(const char *, int, int);
static void poplocalvars(void);
static int unsetvar(const char *);
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
static int setvarsafe(const char *, const char *, int);
#endif
static int varcmp(const char *, const char *);
int nparam; /* # of positional parameters (without $0) */
unsigned char malloc; /* if parameter list dynamically allocated */
char **p; /* parameter list */
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
int optind; /* next parameter to be processed by getopts */
int optoff; /* used by getopts */
#endif
}
}
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
static struct alias *atab[ATABSIZE];
static void setalias(const char *, const char *);
return app;
}
-#endif /* CONFIG_ASH_ALIAS */
+#endif /* ASH_ALIAS */
/* cd.c */
*/
-
static void exverror(int, const char *, va_list) ATTRIBUTE_NORETURN;
/*
errmsg(int e, const char *em)
{
if (e == ENOENT || e == ENOTDIR) {
-
return em;
}
return strerror(e);
}
-
/*
* Evaluate a parse tree. The value is left in the global variable
* exitstatus.
}
-
static void
evalfor(union node *n, int flags)
{
}
-
/*
* Kick off a subshell to evaluate a tree.
*/
}
-
/*
* Compute the names of the files in a redirection list.
*/
}
-
/*
* Evaluate a pipeline. All the processes in the pipeline are children
* of the process creating the pipeline. (This differs from some versions
}
-
/*
* Execute a command inside back quotes. If it's a builtin command, we
* want to save its output in a block obtained from malloc. Otherwise
result->fd, result->buf, result->nleft, result->jp));
}
-#ifdef CONFIG_ASH_CMDCMD
+#if ENABLE_ASH_CMDCMD
static char ** parse_command_args(char **argv, const char **path)
{
char *cp, c;
return *q == '=';
}
-#ifdef CONFIG_ASH_EXPAND_PRMT
+#if ENABLE_ASH_EXPAND_PRMT
static const char *expandstr(const char *ps);
#else
#define expandstr(s) s
spclbltin = IS_BUILTIN_SPECIAL(cmdentry.u.cmd);
if (cmdentry.u.cmd == EXECCMD)
cmd_is_exec++;
-#ifdef CONFIG_ASH_CMDCMD
+#if ENABLE_ASH_CMDCMD
if (cmdentry.u.cmd == COMMANDCMD) {
path = oldpath;
INTON;
shellparam.nparam = argc - 1;
shellparam.p = argv + 1;
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
shellparam.optind = 1;
shellparam.optoff = -1;
#endif
#if ENABLE_FEATURE_SH_STANDALONE_SHELL
if (find_applet_by_name(cmd) != NULL) {
/* re-exec ourselves with the new arguments */
- execve(CONFIG_BUSYBOX_EXEC_PATH,argv,envp);
+ execve(CONFIG_BUSYBOX_EXEC_PATH, argv, envp);
/* If they called chroot or otherwise made the binary no longer
* executable, fall through */
}
}
-
/*
* Called when a cd is done. Marks all commands so the next time they
* are executed they will be rehashed.
}
-
/*
* Fix command hash table when PATH changed.
* Called before PATH is changed. The argument is the new value of PATH;
*/
-#ifdef CONFIG_ASH_CMDCMD
+#if ENABLE_ASH_CMDCMD
static int
describe_command(char *command, int describe_command_verbose)
#else
{
struct cmdentry entry;
struct tblentry *cmdp;
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
const struct alias *ap;
#endif
const char *path = pathval();
goto out;
}
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
/* Then look at the aliases */
if ((ap = lookupalias(command, 0)) != NULL) {
if (describe_command_verbose) {
int err = 0;
for (i = 1; i < argc; i++) {
-#ifdef CONFIG_ASH_CMDCMD
+#if ENABLE_ASH_CMDCMD
err |= describe_command(argv[i], 1);
#else
err |= describe_command(argv[i]);
return err;
}
-#ifdef CONFIG_ASH_CMDCMD
+#if ENABLE_ASH_CMDCMD
static int
commandcmd(int argc, char **argv)
{
CTLVAR,
CTLBACKQ,
CTLBACKQ | CTLQUOTE,
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
CTLENDARI,
#endif
0
length += strcspn(p + length, reject);
c = p[length];
if (c && (!(c & 0x80)
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
|| c == CTLENDARI
#endif
)) {
expbackq(argbackq->n, c, quotes);
argbackq = argbackq->next;
goto start;
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
case CTLENDARI:
p--;
expari(quotes);
}
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
/*
* Expand arithmetic expression. Backup to start of expression,
* evaluate, place result in (backed up) result, adjust string position.
int ifsspc;
int nulonly;
-
start = string;
if (ifslastp != NULL) {
ifsspc = 0;
p = msort(p, len - half); /* sort second half */
lpp = &list;
for (;;) {
-#ifdef CONFIG_LOCALE_SUPPORT
+#if ENABLE_LOCALE_SUPPORT
if (strcoll(p->text, q->text) < 0)
#else
if (strcmp(p->text, q->text) < 0)
int len;
expdest = makestrspace(32, expdest);
-#ifdef CONFIG_ASH_MATH_SUPPORT_64
+#if ENABLE_ASH_MATH_SUPPORT_64
len = fmtstr(expdest, 32, "%lld", (long long) num);
#else
len = fmtstr(expdest, 32, "%ld", num);
#define pgetc_as_macro() (--parsenleft >= 0? SC2INT(*parsenextc++) : preadbuffer())
-#ifdef CONFIG_ASH_OPTIMIZE_FOR_SIZE
+#if ENABLE_ASH_OPTIMIZE_FOR_SIZE
#define pgetc_macro() pgetc()
static int
pgetc(void)
/*
* Same as pgetc(), but ignores PEOA.
*/
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
static int pgetc2(void)
{
int c;
char savec;
while (parsefile->strpush) {
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
if (parsenleft == -1 && parsefile->strpush->ap &&
parsenextc[-1] != ' ' && parsenextc[-1] != '\t') {
return PEOA;
sp = parsefile->strpush = &(parsefile->basestrpush);
sp->prevstring = parsenextc;
sp->prevnleft = parsenleft;
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
sp->ap = (struct alias *)ap;
if (ap) {
((struct alias *)ap)->flag |= ALIASINUSE;
struct strpush *sp = parsefile->strpush;
INTOFF;
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
if (sp->ap) {
if (parsenextc[-1] == ' ' || parsenextc[-1] == '\t') {
checkkwd |= CHKALIAS;
case CTLBACKQ+CTLQUOTE:
str = "\"$(...)\"";
goto dostr;
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
case CTLARI:
str = "$((";
goto dostr;
return retval;
}
-#ifdef CONFIG_ASH_MAIL
+#if ENABLE_ASH_MAIL
/* mail.c */
/*
mail_var_path_changed++;
}
-#endif /* CONFIG_ASH_MAIL */
+#endif /* ASH_MAIL */
/* main.c */
#endif
rootpid = getpid();
-#ifdef CONFIG_ASH_RANDOM_SUPPORT
+#if ENABLE_ASH_RANDOM_SUPPORT
rseed = rootpid + ((time_t)time((time_t *)0));
#endif
init();
inter = 0;
if (iflag && top) {
inter++;
-#ifdef CONFIG_ASH_MAIL
+#if ENABLE_ASH_MAIL
chkmail();
#endif
}
/* NOTREACHED */
}
-#ifdef CONFIG_ASH_BUILTIN_ECHO
+#if ENABLE_ASH_BUILTIN_ECHO
static int
echocmd(int argc, char **argv)
{
}
#endif
-#ifdef CONFIG_ASH_BUILTIN_TEST
+#if ENABLE_ASH_BUILTIN_TEST
static int
testcmd(int argc, char **argv)
{
}
shellparam.p = xargv;
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
shellparam.optind = 1;
shellparam.optoff = -1;
#endif
}
-
/*
* Set the shell parameters.
*/
shellparam.malloc = 1;
shellparam.nparam = nparam;
shellparam.p = newparam;
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
shellparam.optind = 1;
shellparam.optoff = -1;
#endif
}
-
/*
* The shift builtin command.
*/
}
ap2 = shellparam.p;
while ((*ap2++ = *ap1++) != NULL);
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
shellparam.optind = 1;
shellparam.optoff = -1;
#endif
}
-
/*
* The set command builtin.
*/
}
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
static void
getoptsreset(const char *value)
{
}
#endif
-#ifdef CONFIG_LOCALE_SUPPORT
+#if ENABLE_LOCALE_SUPPORT
static void change_lc_all(const char *value)
{
if (value != 0 && *value != 0)
#endif
-#ifdef CONFIG_ASH_RANDOM_SUPPORT
+#if ENABLE_ASH_RANDOM_SUPPORT
/* Roughly copied from bash.. */
static void change_random(const char *value)
{
#endif
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
static int
getopts(char *optstr, char *optvar, char **optfirst, int *param_optind, int *optoff)
{
return getopts(argv[1], argv[2], optbase, &shellparam.optind,
&shellparam.optoff);
}
-#endif /* CONFIG_ASH_GETOPTS */
+#endif /* ASH_GETOPTS */
/*
* XXX - should get rid of. have all builtins use getopt(3). the
}
-
/* parser.c */
static void setprompt(int);
-
-
/*
* Read and parse a command. Returns NEOF on end of file. (NULL is a
* valid parse tree indicating a blank line.)
}
-
static union node *
andor(void)
{
}
-
static union node *
pipeline(void)
{
}
-
static union node *
command(void)
{
n1->type = (lasttoken == TWHILE)? NWHILE : NUNTIL;
n1->nbinary.ch1 = list(0);
if ((got=readtoken()) != TDO) {
-TRACE(("expecting DO got %s %s\n", tokname(got), got == TWORD ? wordtext : ""));
+ TRACE(("expecting DO got %s %s\n", tokname(got),
+ got == TWORD ? wordtext : ""));
synexpect(TDO);
}
n1->nbinary.ch2 = list(0);
int alreadyseen = tokpushback;
#endif
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
top:
#endif
}
if (checkkwd & CHKALIAS) {
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
struct alias *ap;
if ((ap = lookupalias(wordtext, 1)) != NULL) {
if (*ap->val) {
c = pgetc_macro();
if ((c != ' ') && (c != '\t')
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
&& (c != PEOA)
#endif
) {
c = pgetc_macro();
switch (c) {
case ' ': case '\t':
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
case PEOA:
#endif
continue;
USTPUTC(c, out);
}
break;
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
case CLP: /* '(' in arithmetic */
parenlevel++;
USTPUTC(c, out);
default:
if (varnest == 0)
goto endword; /* exit outer loop */
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
if (c != PEOA)
#endif
USTPUTC(c, out);
}
}
endword:
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
if (syntax == ARISYNTAX)
synerror("Missing '))'");
#endif
/* end of readtoken routine */
-
/*
* Check to see whether we are at the end of the here document. When this
* is called, c is set to the first character of the next input line. If
checkend: {
if (eofmark) {
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
if (c == PEOA) {
c = pgetc2();
}
pungetc();
} else if (c == '(') { /* $(command) or $((arith)) */
if (pgetc() == '(') {
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
PARSEARITH();
#else
synerror("We unsupport $((arith))");
/* fall through */
case PEOF:
-#ifdef CONFIG_ASH_ALIAS
+#if ENABLE_ASH_ALIAS
case PEOA:
#endif
startlinno = plinno;
goto parsebackq_newreturn;
}
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
/*
* Parse an arithmetic expansion (indicate start of one and set state)
*/
} /* end of readtoken */
-
/*
* Returns true if the text contains nothing to expand (no dollar signs
* or backquotes).
* should be added here.
*/
-#ifdef CONFIG_ASH_EXPAND_PRMT
+#if ENABLE_ASH_EXPAND_PRMT
static const char *
expandstr(const char *ps)
{
static void setprompt(int whichprompt)
{
const char *prompt;
-#ifdef CONFIG_ASH_EXPAND_PRMT
+#if ENABLE_ASH_EXPAND_PRMT
struct stackmark smark;
#endif
default: /* 0 */
prompt = nullstr;
}
-#ifdef CONFIG_ASH_EXPAND_PRMT
+#if ENABLE_ASH_EXPAND_PRMT
setstackmark(&smark);
stalloc(stackblocksize());
#endif
putprompt(expandstr(prompt));
-#ifdef CONFIG_ASH_EXPAND_PRMT
+#if ENABLE_ASH_EXPAND_PRMT
popstackmark(&smark);
#endif
}
copyfd(f, fd);
close(f);
}
- return;
}
/*
}
-
static void
sharg(union node *arg, FILE *fp)
{
}
-
/*
* Debugging stuff.
*/
#define S_RESET 5 /* temporary - to reset a hard ignored sig */
-
/*
* The trap builtin.
*/
out1fmt("\n\n");
return EXIT_SUCCESS;
}
-#endif /* CONFIG_FEATURE_SH_EXTRA_QUIET */
+#endif /* FEATURE_SH_EXTRA_QUIET */
/*
* Called to exit the shell.
*/
-#ifdef CONFIG_ASH_GETOPTS
+#if ENABLE_ASH_GETOPTS
/*
* Safe version of setvar, returns 1 on success 0 on failure.
*/
}
-
/*
* The export and readonly commands.
*/
}
-
/*
* Find the appropriate entry in the hash table from the name.
*/
}
-
/*
* Compares two strings up to the first = or '\0'. The first
* string must be terminated by '='; the second may be terminated by
return 0;
}
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
static arith_t
dash_arith(const char *s)
{
return !i;
}
-#endif /* CONFIG_ASH_MATH_SUPPORT */
+#endif /* ASH_MATH_SUPPORT */
/* miscbltin.c */
int startword;
int status;
int i;
-#if defined(CONFIG_ASH_READ_NCHARS)
+#if ENABLE_ASH_READ_NCHARS
int nch_flag = 0;
int nchars = 0;
int silent = 0;
struct termios tty, old_tty;
#endif
-#if defined(CONFIG_ASH_READ_TIMEOUT)
+#if ENABLE_ASH_READ_TIMEOUT
fd_set set;
struct timeval ts;
rflag = 0;
prompt = NULL;
-#if defined(CONFIG_ASH_READ_NCHARS) && defined(CONFIG_ASH_READ_TIMEOUT)
+#if ENABLE_ASH_READ_NCHARS && ENABLE_ASH_READ_TIMEOUT
while ((i = nextopt("p:rt:n:s")) != '\0')
-#elif defined(CONFIG_ASH_READ_NCHARS)
+#elif ENABLE_ASH_READ_NCHARS
while ((i = nextopt("p:rn:s")) != '\0')
-#elif defined(CONFIG_ASH_READ_TIMEOUT)
+#elif ENABLE_ASH_READ_TIMEOUT
while ((i = nextopt("p:rt:")) != '\0')
#else
while ((i = nextopt("p:r")) != '\0')
case 'p':
prompt = optionarg;
break;
-#if defined(CONFIG_ASH_READ_NCHARS)
+#if ENABLE_ASH_READ_NCHARS
case 'n':
nchars = strtol(optionarg, &p, 10);
if (*p)
silent = 1;
break;
#endif
-#if defined(CONFIG_ASH_READ_TIMEOUT)
+#if ENABLE_ASH_READ_TIMEOUT
case 't':
ts.tv_sec = strtol(optionarg, &p, 10);
ts.tv_usec = 0;
sh_error("arg count");
if ((ifs = bltinlookup("IFS")) == NULL)
ifs = defifs;
-#if defined(CONFIG_ASH_READ_NCHARS)
+#if ENABLE_ASH_READ_NCHARS
if (nch_flag || silent) {
tcgetattr(0, &tty);
old_tty = tty;
tcsetattr(0, TCSANOW, &tty);
}
#endif
-#if defined(CONFIG_ASH_READ_TIMEOUT)
+#if ENABLE_ASH_READ_TIMEOUT
if (ts.tv_sec || ts.tv_usec) {
FD_ZERO (&set);
FD_SET (0, &set);
i = select(FD_SETSIZE, &set, NULL, NULL, &ts);
if (!i) {
-#if defined(CONFIG_ASH_READ_NCHARS)
+#if ENABLE_ASH_READ_NCHARS
if (nch_flag)
tcsetattr(0, TCSANOW, &old_tty);
#endif
startword = 1;
backslash = 0;
STARTSTACKSTR(p);
-#if defined(CONFIG_ASH_READ_NCHARS)
+#if ENABLE_ASH_READ_NCHARS
while (!nch_flag || nchars--)
#else
for (;;)
STPUTC(c, p);
}
}
-#if defined(CONFIG_ASH_READ_NCHARS)
+#if ENABLE_ASH_READ_NCHARS
if (nch_flag || silent)
tcsetattr(0, TCSANOW, &old_tty);
#endif
}
-#ifdef CONFIG_ASH_MATH_SUPPORT
+#if ENABLE_ASH_MATH_SUPPORT
/* Copyright (c) 2001 Aaron Lehmann <aaronl@vitelus.com>
goto err;
}
/* save to shell variable */
-#ifdef CONFIG_ASH_MATH_SUPPORT_64
+#if ENABLE_ASH_MATH_SUPPORT_64
snprintf(buf, sizeof(buf), "%lld", arith_t_type rez);
#else
snprintf(buf, sizeof(buf), "%ld", arith_t_type rez);
continue;
} else if (is_digit(arithval)) {
numstackptr->var = NULL;
-#ifdef CONFIG_ASH_MATH_SUPPORT_64
+#if ENABLE_ASH_MATH_SUPPORT_64
numstackptr->val = strtoll(expr, (char **) &expr, 0);
#else
numstackptr->val = strtol(expr, (char **) &expr, 0);
++expr;
} /* while */
}
-#endif /* CONFIG_ASH_MATH_SUPPORT */
+#endif /* ASH_MATH_SUPPORT */
#if DEBUG