#else
+/* pretect redefined for test */
+#undef CONFIG_FEATURE_COMMAND_EDITING
+#undef CONFIG_FEATURE_COMMAND_TAB_COMPLETION
+#undef CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
+#undef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
+#undef CONFIG_FEATURE_CLEAN_UP
+
#define CONFIG_FEATURE_COMMAND_EDITING
#define CONFIG_FEATURE_COMMAND_TAB_COMPLETION
#define CONFIG_FEATURE_COMMAND_USERNAME_COMPLETION
int i;
for ( i = 0; i < n_history; i++ ) {
- fputs ( history [i], fp );
- fputc ( '\n', fp );
+ fprintf(fp, "%s\n", history [i]);
}
fclose ( fp );
}
new_settings.c_lflag &= ~ICANON; /* unbuffered input */
/* Turn off echoing and CTRL-C, so we can trap it */
new_settings.c_lflag &= ~(ECHO | ECHONL | ISIG);
-#ifndef linux
/* Hmm, in linux c_cc[] not parsed if set ~ICANON */
new_settings.c_cc[VMIN] = 1;
new_settings.c_cc[VTIME] = 0;
# define _POSIX_VDISABLE '\0'
# endif
new_settings.c_cc[VINTR] = _POSIX_VDISABLE;
-#endif
command[0] = 0;
setTermSettings(0, (void *) &new_settings);
goto_new_line();
command[0] = 0;
len = 0;
-#if !defined(CONFIG_ASH)
lastWasTab = FALSE;
put_prompt();
-#else
- break_out = 2;
-#endif
break;
case 4:
/* Control-d -- Delete one character, or exit
printf("\033[J");
break;
case 12:
- /* Control-l -- clear screen */
+ /* Control-l -- clear screen */
printf("\033[H");
redraw(0, len-cursor);
break;
redraw(cmdedit_y, len -= cursor);
}
break;
+ case 23:
+ /* Control-W -- Remove the last word */
+ while (cursor > 0 && isspace(command[cursor-1]))
+ input_backspace();
+ while (cursor > 0 &&!isspace(command[cursor-1]))
+ input_backspace();
+ break;
case ESC:{
/* escape sequence follows */
if (safe_read(0, &c, 1) < 1)
}
#endif
#endif /* MAX_HISTORY >= 1 */
- if(break_out == 1) {
+ if (break_out > 0) {
command[len++] = '\n'; /* set '\n' */
command[len] = 0;
}
free(cmdedit_prompt);
#endif
cmdedit_reset_term();
-#if !defined(CONFIG_ASH)
return len;
-#else
- return break_out < 0 ? break_out : len;
-#endif
}
#ifdef TEST
const char *bb_applet_name = "debug stuff usage";
-const char *memory_exhausted = "Memory exhausted";
#ifdef CONFIG_FEATURE_NONPRINTABLE_INVERSE_PUT
#include <locale.h>
#endif
while(1) {
int l;
- cmdedit_read_input(prompt, buff);
- l = strlen(buff);
- if(l==0)
- break;
- if(l > 0 && buff[l-1] == '\n')
+ l = cmdedit_read_input(prompt, buff);
+ if(l > 0 && buff[l-1] == '\n') {
buff[l-1] = 0;
- printf("*** cmdedit_read_input() returned line =%s=\n", buff);
+ printf("*** cmdedit_read_input() returned line =%s=\n", buff);
+ } else {
+ break;
+ }
}
- printf("*** cmdedit_read_input() detect ^C\n");
+ printf("*** cmdedit_read_input() detect ^D\n");
return 0;
}