- const char * filename = getenv("LIBBATCH_OVERRIDE_CMDS");
- theIsDefined = (filename != NULL && !string(filename).empty());
- return filename;
+ auto parseCmdFileName = []() -> std::string
+ {
+ const char* cmdFileName = getenv("LIBBATCH_OVERRIDE_CMDS");
+ if (cmdFileName != NULL && !string(cmdFileName).empty())
+ {
+ return cmdFileName;
+ }
+ return {};
+ };
+
+ static const string cmdFileName = parseCmdFileName();
+ return cmdFileName;
+ }
+
+ /*!
+ * Check, if file with overloaded commands is defined by
+ * LIBBATCH_OVERRIDE_CMDS environment variable.
+ * \return true, if file is defined; false - otherwise
+ */
+ bool CommandsOverloader::isCmdFileDefined() const
+ {
+ static const bool isFileDefined = !getCmdFileName().empty();
+ return isFileDefined;