diff --git a/src/shell/main.cpp b/src/shell/main.cpp index b3b73eeba..eb827e3e6 100644 --- a/src/shell/main.cpp +++ b/src/shell/main.cpp @@ -94,27 +94,34 @@ int main (int argc, const char** argv) } } - // if a file is given, read from it + // If a file is given, read from it std::ifstream fin; if (read_from_file) { fin.open (argv[1]); } - // commands may be redirected too + // Commands may be redirected too std::istream &in = read_from_file ? fin : std::cin; - // Begining initilaization - context.initialize (0, NULL); + if (Readline::interactiveMode (in)) + { + // Begining initilaization + if (context.initialize (0, NULL)) + { + return -1; + } - // Display some kind of welcome message. - Color bold (Color::nocolor, Color::nocolor, false, true, false); + // Display some kind of welcome message. + Color bold (Color::nocolor, Color::nocolor, false, true, false); - std::cout << (context.color () ? bold.colorize (PACKAGE_STRING) : PACKAGE_STRING) - << " shell\n\n" - << STRING_CMD_SHELL_HELP1 << '\n' - << STRING_CMD_SHELL_HELP2 << '\n' - << STRING_CMD_SHELL_HELP3 << "\n\n"; + std::cout << (context.color () ? bold.colorize (PACKAGE_STRING) + : PACKAGE_STRING) + << " shell\n\n" + << STRING_CMD_SHELL_HELP1 << '\n' + << STRING_CMD_SHELL_HELP2 << '\n' + << STRING_CMD_SHELL_HELP3 << "\n\n"; + } // Make a copy because context.clear will delete them. std::string permanent_overrides;