@@ -873,6 +873,7 @@ CConfigManager::CConfigManager() {
873873 m_config->registerHandler (&::handleBezier, " bezier" , {false });
874874 m_config->registerHandler (&::handleAnimation, " animation" , {false });
875875 m_config->registerHandler (&::handleSource, " source" , {false });
876+ m_config->registerHandler (&::handleSource, " source-optional" , {false });
876877 m_config->registerHandler (&::handleSubmap, " submap" , {false });
877878 m_config->registerHandler (&::handleBlurLS, " blurls" , {false });
878879 m_config->registerHandler (&::handlePlugin, " plugin" , {false });
@@ -3035,6 +3036,8 @@ std::optional<std::string> CConfigManager::handleSubmap(const std::string&, cons
30353036}
30363037
30373038std::optional<std::string> CConfigManager::handleSource (const std::string& command, const std::string& rawpath) {
3039+ const bool optional = (command == " source-optional" );
3040+
30383041 if (rawpath.length () < 2 ) {
30393042 Debug::log (ERR, " source= path garbage" );
30403043 return " source= path " + rawpath + " bogus!" ;
@@ -3049,6 +3052,10 @@ std::optional<std::string> CConfigManager::handleSource(const std::string& comma
30493052 }};
30503053
30513054 if (auto r = glob (absolutePath (rawpath, m_configCurrentPath).c_str (), GLOB_TILDE, nullptr , glob_buf.get ()); r != 0 ) {
3055+ if (r == GLOB_NOMATCH && optional) {
3056+ Debug::log (LOG, " source-optional= no match found for {}, continuing" , rawpath);
3057+ return {};
3058+ }
30523059 std::string err = std::format (" source= globbing error: {}" , r == GLOB_NOMATCH ? " found no match" : GLOB_ABORTED ? " read error" : " out of memory" );
30533060 Debug::log (ERR, " {}" , err);
30543061 return err;
0 commit comments