diff --git a/gnucash/gnucash-cli.cpp b/gnucash/gnucash-cli.cpp index 0fd2e8df4c6..12188d875c5 100644 --- a/gnucash/gnucash-cli.cpp +++ b/gnucash/gnucash-cli.cpp @@ -160,7 +160,13 @@ Gnucash::GnucashCli::start (int argc, char **argv) std::cout << "Readwrite: " << (m_open_readwrite ? 'Y' : 'N') << std::endl; std::cout << "Interactive: " << (m_interactive ? 'Y' : 'N') << "\n\n" << std::endl; - return Gnucash::run_scripting (m_script_args, m_file_to_load, m_language, m_script, + std::vector newArgv = + { argc ? argv[0] : "", m_file_to_load ? m_file_to_load->c_str() : ""}; + std::transform (m_script_args.begin(), m_script_args.end(), std::back_inserter(newArgv), + [](const std::string& s) { return s.c_str(); }); + // note the vector is valid as long as script_args's strings are not damaged! + + return Gnucash::run_scripting (newArgv, m_file_to_load, m_language, m_script, m_open_readwrite, m_interactive); } diff --git a/gnucash/gnucash-commands.cpp b/gnucash/gnucash-commands.cpp index 8776a377f76..c772ffaff5c 100644 --- a/gnucash/gnucash-commands.cpp +++ b/gnucash/gnucash-commands.cpp @@ -634,7 +634,7 @@ run_python_cli (int argc, char **argv, scripting_args* args) #endif int -Gnucash::run_scripting (std::vector script_args, +Gnucash::run_scripting (std::vector newArgv, const bo_str& file_to_load, std::string& language, const bo_str& script, @@ -666,12 +666,6 @@ Gnucash::run_scripting (std::vector script_args, gnc_shutdown_cli (1); } - std::vector newArgv = - { "gnucash-cli", file_to_load ? file_to_load->c_str() : ""}; - std::transform (script_args.begin(), script_args.end(), std::back_inserter(newArgv), - [](const std::string& s) { return s.c_str(); }); - // note the vector is valid as long as script_args's strings are not damaged! - gnc_prefs_init (); gnc_ui_util_init(); if (file_to_load && boost::filesystem::is_regular_file (*file_to_load)) diff --git a/gnucash/gnucash-commands.hpp b/gnucash/gnucash-commands.hpp index 6c56dfb1e18..55671dcaa55 100644 --- a/gnucash/gnucash-commands.hpp +++ b/gnucash/gnucash-commands.hpp @@ -46,7 +46,7 @@ namespace Gnucash { int report_list (void); int report_show (const bo_str& file_to_load, const bo_str& run_report); - int run_scripting (std::vector m_script_args, + int run_scripting (std::vector newArgv, const bo_str& m_file_to_load, std::string& m_language, const bo_str& m_script,