don't strip paths for -X/x, and for tty output

This commit is contained in:
Jonah Caplan 2021-10-16 14:15:37 -04:00
parent fbc836b553
commit c42bf4b904
2 changed files with 5 additions and 6 deletions

View File

@ -14,7 +14,6 @@ use lazy_static::lazy_static;
use regex::Regex;
use crate::exit_codes::ExitCode;
use crate::filesystem::strip_current_dir;
use self::command::execute_command;
use self::input::{basename, dirname, remove_extension};
@ -145,8 +144,6 @@ impl CommandTemplate {
out_perm: Arc<Mutex<()>>,
buffer_output: bool,
) -> ExitCode {
let input = strip_current_dir(input);
let mut cmd = Command::new(self.args[0].generate(&input, self.path_separator.as_deref()));
for arg in &self.args[1..] {
cmd.arg(arg.generate(&input, self.path_separator.as_deref()));
@ -178,7 +175,7 @@ impl CommandTemplate {
// A single `Tokens` is expected
// So we can directly consume the iterator once and for all
for path in &mut paths {
cmd.arg(arg.generate(strip_current_dir(path), self.path_separator.as_deref()));
cmd.arg(arg.generate(path, self.path_separator.as_deref()));
has_path = true;
}
} else {

View File

@ -250,6 +250,8 @@ fn construct_config(matches: clap::ArgMatches, pattern_regex: &str) -> Result<Co
};
let command = extract_command(&matches, path_separator.as_deref(), colored_output)?;
let istty = unsafe { libc::isatty(libc::STDOUT_FILENO as i32) } != 0;
Ok(Config {
case_sensitive,
search_full_path: matches.is_present("full-path"),
@ -375,8 +377,8 @@ fn construct_config(matches: clap::ArgMatches, pattern_regex: &str) -> Result<Co
None
}
}),
no_strip: matches.is_present("path") || matches.is_present("search-path"),
})
no_strip: matches.is_present("path") || matches.is_present("search-path") || !istty,
})
}
fn extract_command(