handle relative paths without leading ./

This commit is contained in:
Qyriad 2026-01-29 13:52:54 +01:00
parent 551e5a7851
commit 7bce1e7a6e

View file

@ -1,5 +1,7 @@
use std::ffi::OsStr;
use std::io::{self, IsTerminal};
use std::path::Path;
use std::iter;
use std::path::{Path, PathBuf};
use std::process::ExitCode;
use std::{error::Error as StdError, sync::Arc};
@ -20,11 +22,17 @@ fn main_wrapped() -> Result<(), Box<dyn StdError + Send + Sync + 'static>> {
success.expect("logic error in CLI_ENABLE_COLOR");
}
// FIXME: handle relative paths without leading ./
let filepath = Path::new(&args.file);
let filepath: PathBuf = if filepath.is_relative() && !filepath.starts_with("./") {
iter::once(OsStr::new("./"))
.chain(filepath.iter())
.collect()
} else {
filepath.to_path_buf()
};
// Get what file that thing is defined in.
let def_path = append_override::get_where(&args.name, filepath)?;
let def_path = append_override::get_where(&args.name, &filepath)?;
let def_path = Arc::from(def_path);
let mut opts = File::options();
opts.read(true)