Some patches from Gennady Feldman. Fixed a glob problem such that
'ls *.h Config.h' works. Fixed a silly typo with fg/bg process control. Made cmdedit exit sanely when it cannot read input.
This commit is contained in:
parent
d8862928c2
commit
ed424dbf1d
@ -1211,7 +1211,8 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
|
|||||||
fflush(stdout); /* buffered out to fast */
|
fflush(stdout); /* buffered out to fast */
|
||||||
|
|
||||||
if (read(inputFd, &c, 1) < 1)
|
if (read(inputFd, &c, 1) < 1)
|
||||||
return;
|
/* if we can't read input then exit */
|
||||||
|
goto prepare_to_die;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\n':
|
case '\n':
|
||||||
@ -1243,6 +1244,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
|
|||||||
/* Control-d -- Delete one character, or exit
|
/* Control-d -- Delete one character, or exit
|
||||||
* if the len=0 and no chars to delete */
|
* if the len=0 and no chars to delete */
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
|
prepare_to_die:
|
||||||
printf("exit");
|
printf("exit");
|
||||||
clean_up_and_die(0);
|
clean_up_and_die(0);
|
||||||
} else {
|
} else {
|
||||||
|
10
lash.c
10
lash.c
@ -1019,6 +1019,8 @@ static int expand_arguments(char *command)
|
|||||||
(tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
|
(tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
|
||||||
if (*tmpcmd == '\0')
|
if (*tmpcmd == '\0')
|
||||||
break;
|
break;
|
||||||
|
/* we need to trim() the result for glob! */
|
||||||
|
trim(tmpcmd);
|
||||||
retval = glob(tmpcmd, flags, NULL, &expand_result);
|
retval = glob(tmpcmd, flags, NULL, &expand_result);
|
||||||
free(tmpcmd); /* Free mem allocated by strsep_space */
|
free(tmpcmd); /* Free mem allocated by strsep_space */
|
||||||
if (retval == GLOB_NOSPACE) {
|
if (retval == GLOB_NOSPACE) {
|
||||||
@ -1041,10 +1043,8 @@ static int expand_arguments(char *command)
|
|||||||
error_msg(out_of_space);
|
error_msg(out_of_space);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (i>0) {
|
strcat(command+total_length, " ");
|
||||||
strcat(command+total_length, " ");
|
total_length+=1;
|
||||||
total_length+=1;
|
|
||||||
}
|
|
||||||
strcat(command+total_length, expand_result.gl_pathv[i]);
|
strcat(command+total_length, expand_result.gl_pathv[i]);
|
||||||
total_length+=length;
|
total_length+=length;
|
||||||
}
|
}
|
||||||
@ -1803,7 +1803,7 @@ static int busy_loop(FILE * input)
|
|||||||
if (!job_list.fg) {
|
if (!job_list.fg) {
|
||||||
/* move the shell to the foreground */
|
/* move the shell to the foreground */
|
||||||
/* suppress messages when run from /linuxrc mag@sysgo.de */
|
/* suppress messages when run from /linuxrc mag@sysgo.de */
|
||||||
if (tcsetpgrp(0, getpid()) && errno != ENOTTY)
|
if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY)
|
||||||
perror_msg("tcsetpgrp");
|
perror_msg("tcsetpgrp");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
sh.c
10
sh.c
@ -1019,6 +1019,8 @@ static int expand_arguments(char *command)
|
|||||||
(tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
|
(tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
|
||||||
if (*tmpcmd == '\0')
|
if (*tmpcmd == '\0')
|
||||||
break;
|
break;
|
||||||
|
/* we need to trim() the result for glob! */
|
||||||
|
trim(tmpcmd);
|
||||||
retval = glob(tmpcmd, flags, NULL, &expand_result);
|
retval = glob(tmpcmd, flags, NULL, &expand_result);
|
||||||
free(tmpcmd); /* Free mem allocated by strsep_space */
|
free(tmpcmd); /* Free mem allocated by strsep_space */
|
||||||
if (retval == GLOB_NOSPACE) {
|
if (retval == GLOB_NOSPACE) {
|
||||||
@ -1041,10 +1043,8 @@ static int expand_arguments(char *command)
|
|||||||
error_msg(out_of_space);
|
error_msg(out_of_space);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (i>0) {
|
strcat(command+total_length, " ");
|
||||||
strcat(command+total_length, " ");
|
total_length+=1;
|
||||||
total_length+=1;
|
|
||||||
}
|
|
||||||
strcat(command+total_length, expand_result.gl_pathv[i]);
|
strcat(command+total_length, expand_result.gl_pathv[i]);
|
||||||
total_length+=length;
|
total_length+=length;
|
||||||
}
|
}
|
||||||
@ -1803,7 +1803,7 @@ static int busy_loop(FILE * input)
|
|||||||
if (!job_list.fg) {
|
if (!job_list.fg) {
|
||||||
/* move the shell to the foreground */
|
/* move the shell to the foreground */
|
||||||
/* suppress messages when run from /linuxrc mag@sysgo.de */
|
/* suppress messages when run from /linuxrc mag@sysgo.de */
|
||||||
if (tcsetpgrp(0, getpid()) && errno != ENOTTY)
|
if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY)
|
||||||
perror_msg("tcsetpgrp");
|
perror_msg("tcsetpgrp");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1211,7 +1211,8 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
|
|||||||
fflush(stdout); /* buffered out to fast */
|
fflush(stdout); /* buffered out to fast */
|
||||||
|
|
||||||
if (read(inputFd, &c, 1) < 1)
|
if (read(inputFd, &c, 1) < 1)
|
||||||
return;
|
/* if we can't read input then exit */
|
||||||
|
goto prepare_to_die;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\n':
|
case '\n':
|
||||||
@ -1243,6 +1244,7 @@ extern void cmdedit_read_input(char *prompt, char command[BUFSIZ])
|
|||||||
/* Control-d -- Delete one character, or exit
|
/* Control-d -- Delete one character, or exit
|
||||||
* if the len=0 and no chars to delete */
|
* if the len=0 and no chars to delete */
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
|
prepare_to_die:
|
||||||
printf("exit");
|
printf("exit");
|
||||||
clean_up_and_die(0);
|
clean_up_and_die(0);
|
||||||
} else {
|
} else {
|
||||||
|
10
shell/lash.c
10
shell/lash.c
@ -1019,6 +1019,8 @@ static int expand_arguments(char *command)
|
|||||||
(tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
|
(tmpcmd = strsep_space(cmd, &ix)) != NULL; cmd += ix, ix=0) {
|
||||||
if (*tmpcmd == '\0')
|
if (*tmpcmd == '\0')
|
||||||
break;
|
break;
|
||||||
|
/* we need to trim() the result for glob! */
|
||||||
|
trim(tmpcmd);
|
||||||
retval = glob(tmpcmd, flags, NULL, &expand_result);
|
retval = glob(tmpcmd, flags, NULL, &expand_result);
|
||||||
free(tmpcmd); /* Free mem allocated by strsep_space */
|
free(tmpcmd); /* Free mem allocated by strsep_space */
|
||||||
if (retval == GLOB_NOSPACE) {
|
if (retval == GLOB_NOSPACE) {
|
||||||
@ -1041,10 +1043,8 @@ static int expand_arguments(char *command)
|
|||||||
error_msg(out_of_space);
|
error_msg(out_of_space);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (i>0) {
|
strcat(command+total_length, " ");
|
||||||
strcat(command+total_length, " ");
|
total_length+=1;
|
||||||
total_length+=1;
|
|
||||||
}
|
|
||||||
strcat(command+total_length, expand_result.gl_pathv[i]);
|
strcat(command+total_length, expand_result.gl_pathv[i]);
|
||||||
total_length+=length;
|
total_length+=length;
|
||||||
}
|
}
|
||||||
@ -1803,7 +1803,7 @@ static int busy_loop(FILE * input)
|
|||||||
if (!job_list.fg) {
|
if (!job_list.fg) {
|
||||||
/* move the shell to the foreground */
|
/* move the shell to the foreground */
|
||||||
/* suppress messages when run from /linuxrc mag@sysgo.de */
|
/* suppress messages when run from /linuxrc mag@sysgo.de */
|
||||||
if (tcsetpgrp(0, getpid()) && errno != ENOTTY)
|
if (tcsetpgrp(0, getpgrp()) && errno != ENOTTY)
|
||||||
perror_msg("tcsetpgrp");
|
perror_msg("tcsetpgrp");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user