svn commit: trunk/busybox: include libbb shell
vda at busybox.net
vda at busybox.net
Sat Feb 2 18:35:56 UTC 2008
Author: vda
Date: 2008-02-02 10:35:55 -0800 (Sat, 02 Feb 2008)
New Revision: 20932
Log:
msh: fix Ctrl-C handling with line editing
Modified:
trunk/busybox/include/libbb.h
trunk/busybox/libbb/lineedit.c
trunk/busybox/shell/msh.c
Changeset:
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h 2008-02-02 17:54:35 UTC (rev 20931)
+++ trunk/busybox/include/libbb.h 2008-02-02 18:35:55 UTC (rev 20932)
@@ -963,10 +963,9 @@
};
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
Modified: trunk/busybox/libbb/lineedit.c
===================================================================
--- trunk/busybox/libbb/lineedit.c 2008-02-02 17:54:35 UTC (rev 20931)
+++ trunk/busybox/libbb/lineedit.c 2008-02-02 18:35:55 UTC (rev 20932)
@@ -1315,8 +1315,8 @@
#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)
Modified: trunk/busybox/shell/msh.c
===================================================================
--- trunk/busybox/shell/msh.c 2008-02-02 17:54:35 UTC (rev 20931)
+++ trunk/busybox/shell/msh.c 2008-02-02 18:35:55 UTC (rev 20932)
@@ -4836,7 +4836,9 @@
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;
}
More information about the busybox-cvs
mailing list