msh: fix Ctrl-C handling with line editing
authorDenis Vlasenko <vda.linux@googlemail.com>
Sat, 2 Feb 2008 18:35:55 +0000 (18:35 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Sat, 2 Feb 2008 18:35:55 +0000 (18:35 -0000)
include/libbb.h
libbb/lineedit.c
shell/msh.c

index 525162d0534c9d08f94022e0ede823ef28f68ac9..028116fe1fd60e03fca0fca6251decd53f95c7c8 100644 (file)
@@ -963,10 +963,9 @@ enum {
 };
 line_input_t *new_line_input_t(int flags);
 /* Returns:
- * -1 on read errors or EOF, or on bare Ctrl-D.
- * 0  on ctrl-C,
+ * -1 on read errors or EOF, or on bare Ctrl-D,
+ * 0  on ctrl-C (the line entered is still returned in 'command'),
  * >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);
 #else
index d3ee7386e2eeedbec35bedc614170d35f00419c2..c191b0572dd94c95347932aa48088a5d412c65d1 100644 (file)
@@ -1315,8 +1315,8 @@ static void win_changed(int nsig)
 #define CTRL(a) ((a) & ~0x40)
 
 /* Returns:
- * -1 on read errors or EOF, or on bare Ctrl-D.
- * 0  on ctrl-C,
+ * -1 on read errors or EOF, or on bare Ctrl-D,
+ * 0  on ctrl-C (the line entered is still returned in 'command'),
  * >0 length of input string, including terminating '\n'
  */
 int read_line_input(const char *prompt, char *command, int maxsize, line_input_t *st)
index 7371120cab73acc06fac65eabc547b3648981343..9a1be36d99d0f04feb16b42e4a238eab4dbfcf90 100644 (file)
@@ -4836,7 +4836,9 @@ static int filechar(struct ioarg *ap)
                static int position = 0, size = 0;
 
                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);
                        position = 0;
                }