mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-07 01:51:14 -03:00
Fix the BSD builds
These relied on constants that don't actually exist.
This commit is contained in:
@@ -71,13 +71,13 @@ pub mod bsd {
|
||||
use libc;
|
||||
|
||||
pub const SBSIZE: libc::c_int = libc::RLIMIT_SBSIZE;
|
||||
pub const NICE: libc::c_int = libc::RLIMIT_NICE;
|
||||
pub const RSS: libc::c_int = libc::RLIMIT_RSS;
|
||||
pub const NTHR: libc::c_int = libc::RLIMIT_NTHR;
|
||||
pub const SWAP: libc::c_int = libc::RLIMIT_SWAP;
|
||||
pub const KQUEUES: libc::c_int = libc::RLIMIT_KQUEUES;
|
||||
pub const NPTS: libc::c_int = libc::RLIMIT_NPTS;
|
||||
|
||||
pub const NICE: libc::c_int = -1;
|
||||
pub const NTHR: libc::c_int = -1;
|
||||
pub const SIGPENDING: libc::c_int = -1;
|
||||
pub const MSGQUEUE: libc::c_int = -1;
|
||||
pub const RTPRIO: libc::c_int = -1;
|
||||
|
||||
44
src/env/environment.rs
vendored
44
src/env/environment.rs
vendored
@@ -26,7 +26,7 @@
|
||||
use crate::wcstringutil::join_strings;
|
||||
use crate::wutil::{fish_wcstol, wgetcwd, wgettext};
|
||||
|
||||
use libc::{c_int, confstr, uid_t};
|
||||
use libc::{c_int, uid_t};
|
||||
use once_cell::sync::{Lazy, OnceCell};
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::CStr;
|
||||
@@ -566,25 +566,29 @@ fn setup_user(vars: &EnvStack) {
|
||||
}
|
||||
|
||||
pub(crate) static FALLBACK_PATH: Lazy<&[WString]> = Lazy::new(|| {
|
||||
// _CS_PATH: colon-separated paths to find POSIX utilities
|
||||
let buf_size = unsafe { confstr(libc::_CS_PATH, std::ptr::null_mut(), 0) };
|
||||
Box::leak(
|
||||
(if buf_size > 0 {
|
||||
let mut buf = vec![b'\0' as libc::c_char; buf_size];
|
||||
unsafe { confstr(libc::_CS_PATH, buf.as_mut_ptr(), buf_size) };
|
||||
let buf = buf;
|
||||
// safety: buf should contain a null-byte, and is not mutable unless we move ownership
|
||||
let cstr = unsafe { CStr::from_ptr(buf.as_ptr()) };
|
||||
colon_split(&[str2wcstring(cstr.to_bytes())])
|
||||
} else {
|
||||
vec![
|
||||
WString::from_str(env!("PREFIX")) + L!("/bin"),
|
||||
L!("/usr/bin").to_owned(),
|
||||
L!("/bin").to_owned(),
|
||||
]
|
||||
})
|
||||
.into_boxed_slice(),
|
||||
)
|
||||
// _CS_PATH: colon-separated paths to find POSIX utilities. Same as USER_CS_PATH.
|
||||
// BSDs only have the "USER_" form, while Linux only has the "CS_" form.
|
||||
#[cfg(any(apple, bsd))]
|
||||
let cs_path = libc::USER_CS_PATH;
|
||||
#[cfg(not(any(apple, bsd)))]
|
||||
let cs_path = libc::_CS_PATH;
|
||||
|
||||
let buf_size = unsafe { libc::confstr(cs_path, std::ptr::null_mut(), 0) };
|
||||
let paths: Vec<WString> = if buf_size > 0 {
|
||||
let mut buf = vec![b'\0' as libc::c_char; buf_size];
|
||||
unsafe { libc::confstr(cs_path, buf.as_mut_ptr(), buf_size) };
|
||||
let buf = buf;
|
||||
// safety: buf should contain a null-byte, and is not mutable unless we move ownership
|
||||
let cstr = unsafe { CStr::from_ptr(buf.as_ptr()) };
|
||||
colon_split(&[str2wcstring(cstr.to_bytes())])
|
||||
} else {
|
||||
vec![
|
||||
WString::from_str(env!("PREFIX")) + L!("/bin"),
|
||||
WString::from_str("/usr/bin"),
|
||||
WString::from_str("/bin"),
|
||||
]
|
||||
};
|
||||
Box::leak(paths.into_boxed_slice())
|
||||
});
|
||||
|
||||
/// Make sure the PATH variable contains something.
|
||||
|
||||
Reference in New Issue
Block a user