mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 08:51:14 -03:00
Revert "Work around $PATH issues under WSL (#10506)"
This reverts commit 3374692b91.
This commit is contained in:
25
src/path.rs
25
src/path.rs
@@ -2,7 +2,7 @@
|
|||||||
//! for testing if a command with a given name can be found in the PATH, and various other
|
//! for testing if a command with a given name can be found in the PATH, and various other
|
||||||
//! path-related issues.
|
//! path-related issues.
|
||||||
|
|
||||||
use crate::common::{is_windows_subsystem_for_linux as is_wsl, wcs2osstring, wcs2zstring, WSL};
|
use crate::common::{wcs2osstring, wcs2zstring};
|
||||||
use crate::env::{EnvMode, EnvStack, Environment};
|
use crate::env::{EnvMode, EnvStack, Environment};
|
||||||
use crate::expand::{expand_tilde, HOME_DIRECTORY};
|
use crate::expand::{expand_tilde, HOME_DIRECTORY};
|
||||||
use crate::flog::{FLOG, FLOGF};
|
use crate::flog::{FLOG, FLOGF};
|
||||||
@@ -308,29 +308,6 @@ fn path_get_path_core<S: AsRef<wstr>>(cmd: &wstr, pathsv: &[S]) -> GetPathResult
|
|||||||
return GetPathResult::new(test_path(cmd).err(), cmd.to_owned());
|
return GetPathResult::new(test_path(cmd).err(), cmd.to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
// WSLv1/WSLv2 tack on the entire Windows PATH to the end of the PATH environment variable, and
|
|
||||||
// accessing these paths from WSL binaries is pathalogically slow. We also don't expect to find
|
|
||||||
// any "normal" nix binaries under these paths, so we can skip them unless we are executing bins
|
|
||||||
// with Windows-ish names. We try to keep paths manually added to $fish_user_paths by only
|
|
||||||
// chopping off entries after the last "normal" PATH entry.
|
|
||||||
let pathsv = if is_wsl(WSL::Any) && !cmd.contains('.') {
|
|
||||||
let win_path_count = pathsv
|
|
||||||
.iter()
|
|
||||||
.rev()
|
|
||||||
.take_while(|p| {
|
|
||||||
let p = p.as_ref();
|
|
||||||
p.starts_with("/mnt/")
|
|
||||||
&& p.chars()
|
|
||||||
.nth("/mnt/x".len())
|
|
||||||
.map(|c| c == '/')
|
|
||||||
.unwrap_or(false)
|
|
||||||
})
|
|
||||||
.count();
|
|
||||||
&pathsv[..pathsv.len() - win_path_count]
|
|
||||||
} else {
|
|
||||||
pathsv
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut best = noent_res;
|
let mut best = noent_res;
|
||||||
for next_path in pathsv {
|
for next_path in pathsv {
|
||||||
let next_path: &wstr = next_path.as_ref();
|
let next_path: &wstr = next_path.as_ref();
|
||||||
|
|||||||
Reference in New Issue
Block a user