mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-07 13:14:05 +08:00
Make bin path an Option
It is possible we cannot acquire this
This commit is contained in:
parent
aa30b4db4b
commit
7827a8e533
|
@ -167,7 +167,7 @@ fn determine_config_directory_paths(argv0: impl AsRef<Path>) -> ConfigPaths {
|
||||||
data: manifest_dir.join("share"),
|
data: manifest_dir.join("share"),
|
||||||
sysconf: manifest_dir.join("etc"),
|
sysconf: manifest_dir.join("etc"),
|
||||||
doc: manifest_dir.join("user_doc/html"),
|
doc: manifest_dir.join("user_doc/html"),
|
||||||
bin: exec_path.parent().unwrap().to_owned(),
|
bin: Some(exec_path.parent().unwrap().to_owned()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +179,7 @@ fn determine_config_directory_paths(argv0: impl AsRef<Path>) -> ConfigPaths {
|
||||||
data: base_path.join("share/fish"),
|
data: base_path.join("share/fish"),
|
||||||
sysconf: base_path.join("etc/fish"),
|
sysconf: base_path.join("etc/fish"),
|
||||||
doc: base_path.join("share/doc/fish"),
|
doc: base_path.join("share/doc/fish"),
|
||||||
bin: base_path.join("bin"),
|
bin: Some(base_path.join("bin")),
|
||||||
}
|
}
|
||||||
} else if exec_path.ends_with("fish") {
|
} else if exec_path.ends_with("fish") {
|
||||||
FLOG!(
|
FLOG!(
|
||||||
|
@ -191,7 +191,7 @@ fn determine_config_directory_paths(argv0: impl AsRef<Path>) -> ConfigPaths {
|
||||||
data: base_path.join("share"),
|
data: base_path.join("share"),
|
||||||
sysconf: base_path.join("etc"),
|
sysconf: base_path.join("etc"),
|
||||||
doc: base_path.join("user_doc/html"),
|
doc: base_path.join("user_doc/html"),
|
||||||
bin: base_path.to_path_buf(),
|
bin: Some(base_path.to_path_buf()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ fn determine_config_directory_paths(argv0: impl AsRef<Path>) -> ConfigPaths {
|
||||||
data: PathBuf::from(DATA_DIR).join("fish"),
|
data: PathBuf::from(DATA_DIR).join("fish"),
|
||||||
sysconf: PathBuf::from(SYSCONF_DIR).join("fish"),
|
sysconf: PathBuf::from(SYSCONF_DIR).join("fish"),
|
||||||
doc: DOC_DIR.into(),
|
doc: DOC_DIR.into(),
|
||||||
bin: BIN_DIR.into(),
|
bin: Some(BIN_DIR.into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,11 @@ fn determine_config_directory_paths(argv0: impl AsRef<Path>) -> ConfigPaths {
|
||||||
paths.data.display().to_string(),
|
paths.data.display().to_string(),
|
||||||
paths.sysconf.display().to_string(),
|
paths.sysconf.display().to_string(),
|
||||||
paths.doc.display().to_string(),
|
paths.doc.display().to_string(),
|
||||||
paths.bin.display().to_string()
|
paths
|
||||||
|
.bin
|
||||||
|
.clone()
|
||||||
|
.map(|x| x.display().to_string())
|
||||||
|
.unwrap_or("|not found|".to_string()),
|
||||||
);
|
);
|
||||||
|
|
||||||
paths
|
paths
|
||||||
|
|
6
src/env/environment.rs
vendored
6
src/env/environment.rs
vendored
|
@ -611,11 +611,15 @@ pub fn env_init(paths: Option<&ConfigPaths>, do_uvars: bool, default_paths: bool
|
||||||
EnvMode::GLOBAL,
|
EnvMode::GLOBAL,
|
||||||
str2wcstring(paths.doc.as_os_str().as_bytes()),
|
str2wcstring(paths.doc.as_os_str().as_bytes()),
|
||||||
);
|
);
|
||||||
|
if let Some(bp) = &paths.bin {
|
||||||
vars.set_one(
|
vars.set_one(
|
||||||
FISH_BIN_DIR,
|
FISH_BIN_DIR,
|
||||||
EnvMode::GLOBAL,
|
EnvMode::GLOBAL,
|
||||||
str2wcstring(paths.bin.as_os_str().as_bytes()),
|
str2wcstring(bp.as_os_str().as_bytes()),
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
vars.set_empty(FISH_BIN_DIR, EnvMode::GLOBAL);
|
||||||
|
};
|
||||||
|
|
||||||
if default_paths {
|
if default_paths {
|
||||||
let mut scstr = paths.data.clone();
|
let mut scstr = paths.data.clone();
|
||||||
|
|
2
src/env/var.rs
vendored
2
src/env/var.rs
vendored
|
@ -53,7 +53,7 @@ pub struct ConfigPaths {
|
||||||
pub data: PathBuf, // e.g., /usr/local/share
|
pub data: PathBuf, // e.g., /usr/local/share
|
||||||
pub sysconf: PathBuf, // e.g., /usr/local/etc
|
pub sysconf: PathBuf, // e.g., /usr/local/etc
|
||||||
pub doc: PathBuf, // e.g., /usr/local/share/doc/fish
|
pub doc: PathBuf, // e.g., /usr/local/share/doc/fish
|
||||||
pub bin: PathBuf, // e.g., /usr/local/bin
|
pub bin: Option<PathBuf>, // e.g., /usr/local/bin
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A collection of status and pipestatus.
|
/// A collection of status and pipestatus.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user