diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 684b3f9e08ee01682960f218001201d04cb4e880..032e1521e9e3de44a9deab39215f1069ff94f831 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -4,6 +4,8 @@ - cta/CTA#133 - Change severity from ERROR to INFO for "reported a batch of retrieve jobs" log message in Scheduler.cpp - cta/CTA#201 - Improve error message when oracle configured without oracle support - cta/CTA#203 - Refactor cta-restore-deletes-files by using the connection configuration class in standalone_cli_tools/common +### Bug fixes +- cta/CTA#209 - handle if $HOME is not defined when choosing config file for cta-admin # v4.7.13-1 ## Summary diff --git a/cmdline/CtaAdminCmd.cpp b/cmdline/CtaAdminCmd.cpp index 0c01ca0c198789d03058e8f13ba24a2ec72109e8..17bc5dd79b9447d3f20a34411dfa7e45713714f1 100644 --- a/cmdline/CtaAdminCmd.cpp +++ b/cmdline/CtaAdminCmd.cpp @@ -165,10 +165,10 @@ CtaAdminCmd::CtaAdminCmd(int argc, const char *const *const argv) : m_execname(argv[0]) { auto &admincmd = *(m_request.mutable_admincmd()); - + m_request.set_client_cta_version(CTA_VERSION); m_request.set_client_xrootd_ssi_protobuf_interface_version(XROOTD_SSI_PROTOBUF_INTERFACE_VERSION); - + // Strip path from execname size_t p = m_execname.find_last_of('/'); @@ -197,7 +197,7 @@ CtaAdminCmd::CtaAdminCmd(int argc, const char *const *const argv) : } // Help is a special subcommand which suppresses errors and prints usage - + if(argc > argno && std::string(argv[argno]) == "help") { throwUsage(); } @@ -231,16 +231,17 @@ CtaAdminCmd::CtaAdminCmd(int argc, const char *const *const argv) : } const std::string CtaAdminCmd::getConfigFilePath() const { - std::filesystem::path config_file = DEFAULT_CLI_CONFIG; - - const std::filesystem::path home = std::getenv("HOME"); - const std::filesystem::path home_dir_config_file = home / ".cta/cta-cli.conf"; - if(std::filesystem::exists(home_dir_config_file)) { config_file = home_dir_config_file; } + std::filesystem::path config_file = DEFAULT_CLI_CONFIG; - if(m_config) { + if(std::getenv("HOME")) { + const std::filesystem::path home = std::getenv("HOME"); + const std::filesystem::path home_dir_config_file = home / ".cta/cta-cli.conf"; + if(std::filesystem::exists(home_dir_config_file)) { config_file = home_dir_config_file; } + } + if(m_config) { config_file = m_config.value(); - } - return config_file; + } + return config_file; } void CtaAdminCmd::send() const