mirror of
https://github.com/sheumann/hush.git
synced 2025-01-03 00:31:16 +00:00
msh: fix Ctrl-C handling with line editing
This commit is contained in:
parent
a2980c6249
commit
80667e30fb
@ -963,10 +963,9 @@ enum {
|
|||||||
};
|
};
|
||||||
line_input_t *new_line_input_t(int flags);
|
line_input_t *new_line_input_t(int flags);
|
||||||
/* Returns:
|
/* Returns:
|
||||||
* -1 on read errors or EOF, or on bare Ctrl-D.
|
* -1 on read errors or EOF, or on bare Ctrl-D,
|
||||||
* 0 on ctrl-C,
|
* 0 on ctrl-C (the line entered is still returned in 'command'),
|
||||||
* >0 length of input string, including terminating '\n'
|
* >0 length of input string, including terminating '\n'
|
||||||
* [is this true? stores "" in 'command' if return value is 0 or -1]
|
|
||||||
*/
|
*/
|
||||||
int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *state);
|
int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *state);
|
||||||
#else
|
#else
|
||||||
|
@ -1315,8 +1315,8 @@ static void win_changed(int nsig)
|
|||||||
#define CTRL(a) ((a) & ~0x40)
|
#define CTRL(a) ((a) & ~0x40)
|
||||||
|
|
||||||
/* Returns:
|
/* Returns:
|
||||||
* -1 on read errors or EOF, or on bare Ctrl-D.
|
* -1 on read errors or EOF, or on bare Ctrl-D,
|
||||||
* 0 on ctrl-C,
|
* 0 on ctrl-C (the line entered is still returned in 'command'),
|
||||||
* >0 length of input string, including terminating '\n'
|
* >0 length of input string, including terminating '\n'
|
||||||
*/
|
*/
|
||||||
int read_line_input(const char *prompt, char *command, int maxsize, line_input_t *st)
|
int read_line_input(const char *prompt, char *command, int maxsize, line_input_t *st)
|
||||||
|
@ -4836,7 +4836,9 @@ static int filechar(struct ioarg *ap)
|
|||||||
static int position = 0, size = 0;
|
static int position = 0, size = 0;
|
||||||
|
|
||||||
while (size == 0 || position >= size) {
|
while (size == 0 || position >= size) {
|
||||||
read_line_input(current_prompt, filechar_cmdbuf, BUFSIZ, line_input_state);
|
/* Repeat if Ctrl-C is pressed. TODO: exit on -1 (error/EOF)? */
|
||||||
|
while (read_line_input(current_prompt, filechar_cmdbuf, BUFSIZ, line_input_state) == 0)
|
||||||
|
continue;
|
||||||
size = strlen(filechar_cmdbuf);
|
size = strlen(filechar_cmdbuf);
|
||||||
position = 0;
|
position = 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user