}
+static inline int
+goodname(const char *p)
+{
+ return !*endofname(p);
+}
+
/*
* Search for a command. This is called before we fork so that the
* location of the command will be available in the parent as well as
- * the child.
+ * the child. The check for "goodname" is an overly conservative
+ * check that the name will not be subject to expansion.
*/
static void
struct cmdentry entry;
if (n->type == NCMD && n->ncmd.args)
- find_command(n->ncmd.args->narg.text, &entry, 0, pathval());
+ if (goodname(n->ncmd.args->narg.text))
+ find_command(n->ncmd.args->narg.text, &entry, 0,
+ pathval());
}
nr = cmdedit_read_input((char *) cmdedit_prompt, buf);
if(nr == 0) {
/* Ctrl+C presend */
- raise(SIGINT);
+ if(trap[SIGINT]) {
+ buf[0] = '\n';
+ buf[1] = 0;
+ raise(SIGINT);
+ return 1;
+ }
goto retry;
}
if(nr < 0) {
const char *p;
char s[2];
+ if (!n)
+ return;
switch (n->type) {
default:
#if DEBUG
static void setprompt(int);
-static inline int
-goodname(const char *p)
-{
- return !*endofname(p);
-}
static inline int
isassignment(const char *p)
* more letters, underscores, and digits).
*/
-char *
+static char *
endofname(const char *name)
{
char *p;
struct jmploc loc;
char *p;
int status;
+ int jmp;
+ jmp = setjmp(loc.loc);
status = exitstatus;
TRACE(("pid %d, exitshell(%d)\n", getpid(), status));
- if (setjmp(loc.loc)) {
+ if (jmp)
goto out;
- }
handler = &loc;
if ((p = trap[0]) != NULL && *p != '\0') {
trap[0] = NULL;
struct rlimit limit;
what = 'f';
- while ((optc = nextopt("HSatfdsmcnplvw")) != '\0')
+ while ((optc = nextopt("HSa"
+#ifdef RLIMIT_CPU
+ "t"
+#endif
+#ifdef RLIMIT_FSIZE
+ "f"
+#endif
+#ifdef RLIMIT_DATA
+ "d"
+#endif
+#ifdef RLIMIT_STACK
+ "s"
+#endif
+#ifdef RLIMIT_CORE
+ "c"
+#endif
+#ifdef RLIMIT_RSS
+ "m"
+#endif
+#ifdef RLIMIT_MEMLOCK
+ "l"
+#endif
+#ifdef RLIMIT_NPROC
+ "p"
+#endif
+#ifdef RLIMIT_NOFILE
+ "n"
+#endif
+#ifdef RLIMIT_AS
+ "v"
+#endif
+#ifdef RLIMIT_LOCKS
+ "w"
+#endif
+ )) != '\0')
switch (optc) {
case 'H':
how = HARD;
case 3:
/* Control-c -- stop gathering input */
goto_new_line();
+#ifndef CONFIG_ASH
command[0] = 0;
len = 0;
lastWasTab = FALSE;
put_prompt();
+#else
+ len = 0;
+ break_out = -1; /* for control traps */
+#endif
break;
case 4:
/* Control-d -- Delete one character, or exit
/* cmdedit_reset_term() called in atexit */
exit(EXIT_SUCCESS);
#else
- break_out = -1; /* for control stoped jobs */
+ len = break_out = -1; /* for control stoped jobs */
break;
#endif
} else {
/* cleanup may be saved current command line */
free(history[MAX_HISTORY]);
history[MAX_HISTORY] = 0;
- if (len) { /* no put empty line */
+ if (len> 0) { /* no put empty line */
int i = n_history;
/* After max history, remove the oldest command */
if (i >= MAX_HISTORY) {
}
#else /* MAX_HISTORY < 1 */
#if defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
- if (len) { /* no put empty line */
+ if (len > 0) { /* no put empty line */
num_ok_lines++;
}
#endif