#define IS_BUILTIN_REGULAR(builtincmd) ((builtincmd)->name[0] & 2)
#define IS_BUILTIN_ASSIGN(builtincmd) ((builtincmd)->name[0] & 4)
+/* make sure to keep these in proper order since it is searched via bsearch() */
static const struct builtincmd builtincmd[] = {
{ BUILTIN_SPEC_REG ".", dotcmd },
{ BUILTIN_SPEC_REG ":", truecmd },
{ BUILTIN_SPEC_REG_ASSG "readonly", exportcmd },
{ BUILTIN_SPEC_REG "return", returncmd },
{ BUILTIN_SPEC_REG "set", setcmd },
- { BUILTIN_SPEC_REG "source", dotcmd },
{ BUILTIN_SPEC_REG "shift", shiftcmd },
+ { BUILTIN_SPEC_REG "source", dotcmd },
#ifdef CONFIG_ASH_BUILTIN_TEST
{ BUILTIN_REGULAR "test", testcmd },
#endif
static int dotrap(void);
static void setinteractive(int);
static void exitshell(void) ATTRIBUTE_NORETURN;
-static int decode_signal(const char *, int);
/*
* This routine is called when an error or an interrupt occurs in an
int i;
intpending = 0;
-#if 0
- /* comment by vodz: its strange for me, this programm don`t use other
- signal block */
- sigsetmask(0);
-#endif
i = EXSIG;
if (gotsig[SIGINT - 1] && !trap[SIGINT]) {
if (!(rootshell && iflag)) {
}
sp = arglist.list;
}
- bb_full_write(preverrout_fd, "\n", 1);
+ full_write(preverrout_fd, "\n", 1);
}
cmd_is_exec = 0;
flushall();
cmddone:
exitstatus |= ferror(stdout);
+ clearerr(stdout);
commandname = savecmdname;
exsig = 0;
handler = savehandler;
#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
if(find_applet_by_name(cmd) != NULL) {
/* re-exec ourselves with the new arguments */
- execve("/proc/self/exe",argv,envp);
- /* If proc isn't mounted, try hardcoded path to busybox binary*/
- execve("/bin/busybox",argv,envp);
+ execve(CONFIG_BUSYBOX_EXEC_PATH,argv,envp);
/* If they called chroot or otherwise made the binary no longer
* executable, fall through */
}
{
herefd = fd;
expandarg(arg, (struct arglist *)NULL, 0);
- bb_full_write(fd, stackblock(), expdest - (char *)stackblock());
+ full_write(fd, stackblock(), expdest - (char *)stackblock());
}
{
#ifdef CONFIG_ASH_EXPAND_PRMT
free(cmdedit_prompt);
- cmdedit_prompt = bb_xstrdup(s);
+ cmdedit_prompt = xstrdup(s);
#else
cmdedit_prompt = s;
#endif
}
if (**++argv == '-') {
- signo = decode_signal(*argv + 1, 1);
+ signo = get_signum(*argv + 1);
if (signo < 0) {
int c;
list = 1;
break;
case 's':
- signo = decode_signal(optionarg, 1);
+ signo = get_signum(optionarg);
if (signo < 0) {
sh_error(
"invalid signal number or name: %s",
if (!*argv) {
for (i = 1; i < NSIG; i++) {
- name = u_signal_names(0, &i, 1);
- if (name)
+ name = get_signame(i);
+ if (isdigit(*name))
out1fmt(snlfmt, name);
}
return 0;
}
- name = u_signal_names(*argptr, &signo, -1);
- if (name)
+ name = get_signame(signo);
+ if (isdigit(*name))
out1fmt(snlfmt, name);
else
sh_error("invalid signal number or exit status: %s", *argptr);
int status = 0;
for (sp = cmdenviron; sp; sp = sp->next)
- setvareq(bb_xstrdup(sp->text), VSTRFIXED | VTEXTFIXED);
+ setvareq(xstrdup(sp->text), VSTRFIXED | VTEXTFIXED);
if (argc >= 2) { /* That's what SVR2 does */
char *fullname;
{
size_t len = stackblocksize();
if (herefd >= 0 && len >= 1024) {
- bb_full_write(herefd, stackblock(), len);
+ full_write(herefd, stackblock(), len);
return stackblock();
}
growstackblock();
#ifdef CONFIG_ASH_GETOPTS
static void
-getoptsreset(value)
- const char *value;
+getoptsreset(const char *value)
{
shellparam.optind = number(value);
shellparam.optoff = -1;
#define xxreadtoken_singles \
(sizeof(xxreadtoken_chars) - xxreadtoken_doubles - 1)
-static int xxreadtoken()
+static int xxreadtoken(void)
{
int c;
if (redir->type == NHERE) {
len = strlen(redir->nhere.doc->narg.text);
if (len <= PIPESIZE) {
- bb_full_write(pip[1], redir->nhere.doc->narg.text, len);
+ full_write(pip[1], redir->nhere.doc->narg.text, len);
goto out;
}
}
#endif
signal(SIGPIPE, SIG_DFL);
if (redir->type == NHERE)
- bb_full_write(pip[1], redir->nhere.doc->narg.text, len);
+ full_write(pip[1], redir->nhere.doc->narg.text, len);
else
expandhere(redir->nhere.doc, pip[1]);
_exit(0);
if (trap[signo] != NULL) {
const char *sn;
- sn = u_signal_names(0, &signo, 0);
- if (sn == NULL)
- sn = "???";
+ sn = get_signame(signo);
out1fmt("trap -- %s %s\n",
single_quote(trap[signo]), sn);
}
else
action = *ap++;
while (*ap) {
- if ((signo = decode_signal(*ap, 0)) < 0)
+ if ((signo = get_signum(*ap)) < 0)
sh_error("%s: bad trap", *ap);
INTOFF;
if (action) {
/* NOTREACHED */
}
-static int decode_signal(const char *string, int minsig)
-{
- int signo;
- const char *name = u_signal_names(string, &signo, minsig);
-
- return name ? signo : -1;
-}
-
/* var.c */
static struct var *vartab[VTABSIZE];
static arith_t arith (const char *expr, int *perrcode)
{
- register char arithval; /* Current character under analysis */
+ char arithval; /* Current character under analysis */
operator lasttok, op;
operator prec;