From 6981893a2e92b93fc1a91275ca8eedb4828501f2 Mon Sep 17 00:00:00 2001 From: Haitham Gad Date: Sun, 28 Apr 2013 22:04:33 -0400 Subject: [PATCH] Disallowing tasksh to start in interactive mode (not in batch mode) if no ~/.taskrc exists --- src/shell/main.cpp | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) 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;