Vodz last_patch_125_2, this patch have:
- synced with dash 0.4.21 - better handle trap "cmds..." SIGINT (strange, i make bad hack for ash and cmdedit, but this work only with this...) - may be haven`t problem with Ctrl-D
This commit is contained in:
parent
31b98dd097
commit
16e45d7e29
70
shell/ash.c
70
shell/ash.c
@ -3476,10 +3476,17 @@ funcdone:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
goodname(const char *p)
|
||||||
|
{
|
||||||
|
return !*endofname(p);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Search for a command. This is called before we fork so that the
|
* 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
|
* 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
|
static void
|
||||||
@ -3488,7 +3495,9 @@ prehash(union node *n)
|
|||||||
struct cmdentry entry;
|
struct cmdentry entry;
|
||||||
|
|
||||||
if (n->type == NCMD && n->ncmd.args)
|
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -6020,7 +6029,12 @@ retry:
|
|||||||
nr = cmdedit_read_input((char *) cmdedit_prompt, buf);
|
nr = cmdedit_read_input((char *) cmdedit_prompt, buf);
|
||||||
if(nr == 0) {
|
if(nr == 0) {
|
||||||
/* Ctrl+C presend */
|
/* Ctrl+C presend */
|
||||||
raise(SIGINT);
|
if(trap[SIGINT]) {
|
||||||
|
buf[0] = '\n';
|
||||||
|
buf[1] = 0;
|
||||||
|
raise(SIGINT);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
if(nr < 0) {
|
if(nr < 0) {
|
||||||
@ -7425,6 +7439,8 @@ cmdtxt(union node *n)
|
|||||||
const char *p;
|
const char *p;
|
||||||
char s[2];
|
char s[2];
|
||||||
|
|
||||||
|
if (!n)
|
||||||
|
return;
|
||||||
switch (n->type) {
|
switch (n->type) {
|
||||||
default:
|
default:
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
@ -9295,11 +9311,6 @@ static void synerror(const char *) __attribute__((__noreturn__));
|
|||||||
static void setprompt(int);
|
static void setprompt(int);
|
||||||
|
|
||||||
|
|
||||||
static inline int
|
|
||||||
goodname(const char *p)
|
|
||||||
{
|
|
||||||
return !*endofname(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
isassignment(const char *p)
|
isassignment(const char *p)
|
||||||
@ -10755,7 +10766,7 @@ noexpand(char *text)
|
|||||||
* more letters, underscores, and digits).
|
* more letters, underscores, and digits).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *
|
static char *
|
||||||
endofname(const char *name)
|
endofname(const char *name)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
@ -11835,12 +11846,13 @@ exitshell(void)
|
|||||||
struct jmploc loc;
|
struct jmploc loc;
|
||||||
char *p;
|
char *p;
|
||||||
int status;
|
int status;
|
||||||
|
int jmp;
|
||||||
|
|
||||||
|
jmp = setjmp(loc.loc);
|
||||||
status = exitstatus;
|
status = exitstatus;
|
||||||
TRACE(("pid %d, exitshell(%d)\n", getpid(), status));
|
TRACE(("pid %d, exitshell(%d)\n", getpid(), status));
|
||||||
if (setjmp(loc.loc)) {
|
if (jmp)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
handler = &loc;
|
handler = &loc;
|
||||||
if ((p = trap[0]) != NULL && *p != '\0') {
|
if ((p = trap[0]) != NULL && *p != '\0') {
|
||||||
trap[0] = NULL;
|
trap[0] = NULL;
|
||||||
@ -12713,7 +12725,41 @@ ulimitcmd(int argc, char **argv)
|
|||||||
struct rlimit limit;
|
struct rlimit limit;
|
||||||
|
|
||||||
what = 'f';
|
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) {
|
switch (optc) {
|
||||||
case 'H':
|
case 'H':
|
||||||
how = HARD;
|
how = HARD;
|
||||||
|
@ -1283,10 +1283,15 @@ int cmdedit_read_input(char *prompt, char command[BUFSIZ])
|
|||||||
case 3:
|
case 3:
|
||||||
/* Control-c -- stop gathering input */
|
/* Control-c -- stop gathering input */
|
||||||
goto_new_line();
|
goto_new_line();
|
||||||
|
#ifndef CONFIG_ASH
|
||||||
command[0] = 0;
|
command[0] = 0;
|
||||||
len = 0;
|
len = 0;
|
||||||
lastWasTab = FALSE;
|
lastWasTab = FALSE;
|
||||||
put_prompt();
|
put_prompt();
|
||||||
|
#else
|
||||||
|
len = 0;
|
||||||
|
break_out = -1; /* for control traps */
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
/* Control-d -- Delete one character, or exit
|
/* Control-d -- Delete one character, or exit
|
||||||
@ -1299,7 +1304,7 @@ prepare_to_die:
|
|||||||
/* cmdedit_reset_term() called in atexit */
|
/* cmdedit_reset_term() called in atexit */
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
#else
|
#else
|
||||||
break_out = -1; /* for control stoped jobs */
|
len = break_out = -1; /* for control stoped jobs */
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
@ -1493,7 +1498,7 @@ rewrite_line:
|
|||||||
/* cleanup may be saved current command line */
|
/* cleanup may be saved current command line */
|
||||||
free(history[MAX_HISTORY]);
|
free(history[MAX_HISTORY]);
|
||||||
history[MAX_HISTORY] = 0;
|
history[MAX_HISTORY] = 0;
|
||||||
if (len) { /* no put empty line */
|
if (len> 0) { /* no put empty line */
|
||||||
int i = n_history;
|
int i = n_history;
|
||||||
/* After max history, remove the oldest command */
|
/* After max history, remove the oldest command */
|
||||||
if (i >= MAX_HISTORY) {
|
if (i >= MAX_HISTORY) {
|
||||||
@ -1510,7 +1515,7 @@ rewrite_line:
|
|||||||
}
|
}
|
||||||
#else /* MAX_HISTORY < 1 */
|
#else /* MAX_HISTORY < 1 */
|
||||||
#if defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
|
#if defined(CONFIG_FEATURE_SH_FANCY_PROMPT)
|
||||||
if (len) { /* no put empty line */
|
if (len > 0) { /* no put empty line */
|
||||||
num_ok_lines++;
|
num_ok_lines++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user