int main(int argc, char* argv[]) { char *input; char *str; char *tokv[5]; int tokc; char *expansion; int result; printf("Press Ctrl-D or enter \"exit\" to end session.\n" "Enter \"help\" to display a command list.\n"); using_history(); try { Shell shell; while (!shell.exitFlag()) { input = readline("bossa> "); if (!input) { printf("\n"); break; } for (str = input; *str && isspace(*str); str++); if (*str) { result = history_expand(input, &expansion); if (result >= 0 && result != 2) { add_history(expansion); tokc = split(expansion, tokv, ARRAY_SIZE(tokv)); shell.invoke(tokv, tokc); } free(expansion); } free(input); } } catch(...) { printf("\nUnhandled exception\n"); return 1; } return 0; }