From b440dc830b8a93332578287c08410fb7200d42c8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 21 Apr 2018 16:42:54 +0200 Subject: [PATCH] behave like standard Python interpreter in console mode if no file name is passed --- src/App/Application.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 8bc309bfe7..bd951cbbdc 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1619,7 +1619,7 @@ std::list Application::processFiles(const std::list& f processed.push_back(*it); Base::Console().Log("Command line open: %s.open(u\"%s\")\n",mods.front().c_str(),escapedstr.c_str()); } - else { + else if (file.exists()) { Console().Warning("File format not supported: %s \n", file.filePath().c_str()); } } @@ -1642,12 +1642,21 @@ void Application::processCmdLineFiles(void) { // process files passed to command line std::list files = getCmdLineFiles(); - processFiles(files); + std::list processed = processFiles(files); if (files.empty()) { if (mConfig["RunMode"] == "Exit") mConfig["RunMode"] = "Cmd"; } + else if (processed.empty() && files.size() == 1 && mConfig["RunMode"] == "Cmd") { + // In case we are in console mode and the argument is not a file but Python code + // then execute it. This is to behave like the standard Python executable. + Base::FileInfo file(files.front()); + if (!file.exists()) { + Interpreter().runString(files.front().c_str()); + mConfig["RunMode"] = "Exit"; + } + } const std::map& cfg = Application::Config(); std::map::const_iterator it = cfg.find("SaveFile");