Repositories / jai.git
jai.git
Clone (read-only): git clone http://git.guha-anderson.com/git/jai.git
@@ -178,7 +178,11 @@ opencode`): `-C` *file*, `--conf `*file* : Specifies the configuration file to read. If *file* does not - contain a `/`, the file is relative to `$HOME/.jai`. + contain a `/`, the file is relative to `$HOME/.jai`. Also, if + *file* resides in `$HOME/.jai` and does not contain a `/`, you can + omit any `.conf` extension. So `-C default` is equivalent to `-C + default.conf` (assuming you don't have a file `default` in addition + to `default.conf`). If no configuration file is specified, the default is based on the *cmd* argument. If *cmd* contains no slashes and does not start
@@ -124,6 +124,13 @@ bool Config::parse_config_file(path file, Options *opts) { bool slash = std::ranges::distance(file.begin(), file.end()) > 1; + + if (struct stat sb; !slash && file.extension() != ".conf" && + fstatat(home_jai(), file.c_str(), &sb, 0) && errno == ENOENT && + ~fstatat(home_jai(), cat(file, ".conf").c_str(), &sb, 0) && + S_ISREG(sb.st_mode)) + file += ".conf"; + auto ld = (slash ? cwd() : homejaipath_) / file; if (auto [_it, ok] = config_loop_detect_.insert(ld); !ok) err<Options::Error>("configuration loop");