handle relative paths without leading ./
This commit is contained in:
parent
551e5a7851
commit
7bce1e7a6e
1 changed files with 11 additions and 3 deletions
14
src/main.rs
14
src/main.rs
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue