* Copyright (c) 1989, 1991, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
+ * Copyright (c) 1997-2003 Herbert Xu <herbert@debian.org>
+ * was re-ported from NetBSD and debianized.
+ *
+ *
* This code is derived from software contributed to Berkeley by
* Kenneth Almquist.
*
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- * This version of ash is adapted from the source in Debian's ash 0.3.8-5
- * package.
- * Maintainer Herbert Xu <herbert@debian.org> (C) 1997-2002
*
* Modified by Vladimir Oleynik <dzo@simtreas.ru> to be used in busybox
*
*
- * Original copyright notice is retained at the end of this file.
+ * Original BSD copyright notice is retained at the end of this file.
*/
/*
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin";
#ifdef IFS_BROKEN
static const char defifsvar[] = "IFS= \t\n";
-#endif
+#define defifs (defifsvar + 4)
+#else
static const char defifs[] = " \t\n";
+#endif
+
static struct var varinit[] = {
#ifdef IFS_BROKEN
* have parseword (readtoken1?) handle both words and redirection.]
*/
+#define NEW_xxreadtoken
+#ifdef NEW_xxreadtoken
+
+/* singles must be first! */
+static const char xxreadtoken_chars[7] = { '\n', '(', ')', '&', '|', ';', 0 };
+
+static const char xxreadtoken_tokens[] = {
+ TNL, TLP, TRP, /* only single occurrence allowed */
+ TBACKGND, TPIPE, TSEMI, /* if single occurrence */
+ TEOF, /* corresponds to trailing nul */
+ TAND, TOR, TENDCASE, /* if double occurrence */
+};
+
+#define xxreadtoken_doubles \
+ (sizeof(xxreadtoken_tokens) - sizeof(xxreadtoken_chars))
+#define xxreadtoken_singles \
+ (sizeof(xxreadtoken_chars) - xxreadtoken_doubles - 1)
+
+static int xxreadtoken()
+{
+ int c;
+
+ if (tokpushback) {
+ tokpushback = 0;
+ return lasttoken;
+ }
+ if (needprompt) {
+ setprompt(2);
+ needprompt = 0;
+ }
+ startlinno = plinno;
+ for (;;) { /* until token or start of word found */
+ c = pgetc_macro();
+
+ if ((c != ' ') && (c != '\t')
+#ifdef CONFIG_ASH_ALIAS
+ && (c != PEOA)
+#endif
+ ) {
+ if (c == '#') {
+ while ((c = pgetc()) != '\n' && c != PEOF);
+ pungetc();
+ } else if (c == '\\') {
+ if (pgetc() != '\n') {
+ pungetc();
+ goto READTOKEN1;
+ }
+ startlinno = ++plinno;
+ if (doprompt)
+ setprompt(2);
+ } else {
+ const char *p
+ = xxreadtoken_chars + sizeof(xxreadtoken_chars) - 1;
+
+ if (c != PEOF) {
+ if (c == '\n') {
+ plinno++;
+ needprompt = doprompt;
+ }
+
+ p = strchr(xxreadtoken_chars, c);
+ if (p == NULL) {
+ READTOKEN1:
+ return readtoken1(c, BASESYNTAX, (char *) NULL, 0);
+ }
+
+ if (p - xxreadtoken_chars >= xxreadtoken_singles) {
+ if (pgetc() == *p) { /* double occurrence? */
+ p += xxreadtoken_doubles + 1;
+ } else {
+ pungetc();
+ }
+ }
+ }
+
+ return lasttoken = xxreadtoken_tokens[p - xxreadtoken_chars];
+ }
+ }
+ }
+}
+
+
+#else
#define RETURN(token) return lasttoken = token
static int
return readtoken1(c, BASESYNTAX, (char *)NULL, 0);
#undef RETURN
}
-
+#endif /* NEW_xxreadtoken */
/*
}
-
-
-
-
/*
* Undo the effects of the last redirection.
*/
}
-
/*
* Copy a file descriptor to be >= to. Returns -1
* if the source file descriptor is closed, EMPTY if there are no unused
}
-
static void
shcmd(union node *cmd, FILE *fp)
{
}
-
/*
* Clear traps on a fork.
*/
}
-
/*
* Set the signal handler for the specified signal. The routine figures
* out what it should be set to.
}
-
/*
* Signal handler.
*/
}
-
/*
* Called to execute a trap. Perhaps we should avoid entering new trap
* handlers while we are executing a trap handler.
}
-
/*
* Controls whether the shell is interactive or not.
*/
-
void
setinteractive(int on)
{
}
#endif
out:
- out1c('\n');
_exit(status);
/* NOTREACHED */
}
}
-
/*
* Same as setvar except that the variable and value are passed in
* the first argument as name=value. Since the first argument will
}
-
/*
* Process a linked list of variable assignments.
*/
}
-
/*
* Search the environment of a builtin command.
*/
}
-
/*
* Generate a list of variables satisfying the given conditions.
*/
}
-
/*
* POSIX requires that 'set' (but not export or readonly) output the
* variables in lexicographic order - by the locale's collating order (sigh).
-
/*
* Called after a function returns.
* Interrupts must be off.
if (all || argptr[1])
error("too many arguments");
- if (strcmp(p, "unlimited") == 0)
+ if (strncmp(p, "unlimited\n", 9) == 0)
val = RLIM_INFINITY;
else {
val = (rlim_t) 0;
/*
* Termios command line History and Editting.
*
- * Copyright (c) 1986-2001 may safely be consumed by a BSD or GPL license.
+ * Copyright (c) 1986-2003 may safely be consumed by a BSD or GPL license.
* Written by: Vladimir Oleynik <dzo@simtreas.ru>
*
* Used ideas:
* Adam Rogoyski <rogoyski@cs.utexas.edu>
* Dave Cinege <dcinege@psychosis.com>
* Jakub Jelinek (c) 1995
- * Erik Andersen <andersee@debian.org> (Majorly adjusted for busybox)
+ * Erik Andersen <andersen@codepoet.org> (Majorly adjusted for busybox)
*
* This code is 'as is' with no warranty.
*
#endif /* CONFIG_FEATURE_COMMAND_TAB_COMPLETION */
-/* It seems that libc5 doesn't know what a sighandler_t is... */
-#if (__GLIBC__ <= 2) && (__GLIBC_MINOR__ < 1)
-typedef void (*sighandler_t) (int);
-#endif
-
static void cmdedit_setwidth(int w, int redraw_flg);
static void win_changed(int nsig)
if ( s )
fputs(s, stdout);
}
+
static inline void beep(void)
{
putchar('\007');