mirror of https://github.com/sharkdp/fd.git
Added windows specific logic to check if we're in a unix like shell
This commit is contained in:
parent
44ee5a0b85
commit
062ba4b8ae
|
@ -15,6 +15,8 @@ use std::ops::Deref;
|
|||
use std::path::{self, Path, PathBuf, Component};
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
#[cfg(windows)]
|
||||
use std::env;
|
||||
|
||||
use ansi_term;
|
||||
|
||||
|
@ -33,6 +35,20 @@ pub fn print_entry(entry: &PathBuf, config: &FdOptions) {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn get_separator() -> String {
|
||||
path::MAIN_SEPARATOR.to_string()
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn get_separator() -> String {
|
||||
if let Some(_) = env::var_os("PATH") {
|
||||
String::from("/")
|
||||
} else {
|
||||
path::MAIN_SEPARATOR.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
fn print_entry_colorized(path: &Path, config: &FdOptions, ls_colors: &LsColors) -> io::Result<()> {
|
||||
let default_style = ansi_term::Style::default();
|
||||
|
||||
|
@ -61,7 +77,9 @@ fn print_entry_colorized(path: &Path, config: &FdOptions, ls_colors: &LsColors)
|
|||
// RootDir is already a separator.
|
||||
Component::RootDir => String::new(),
|
||||
// Everything else uses a separator that is painted the same way as the component.
|
||||
_ => style.paint(path::MAIN_SEPARATOR.to_string()).to_string(),
|
||||
_ => {
|
||||
style.paint(get_separator()).to_string()
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue