Ports ZIG/src/os for Linux into ghostty-os: XDG dirs, home dir, hostname, env/PATH helpers, passwd lookup (via nix), shell detection, resources dir discovery, string encodings (printf-q, URL percent), systemd sd_notify, i18n via gettextrs, xdg-open, desktop/cgroup/kernel info, temp dirs, URI parsing (port of std.Uri incl. Ghostty's extra options), and a zbus-based Flatpak HostCommand implementation. The crate stays free of unsafe. Consequences, all tracked as TODO(integration) in docs/rewrite/notes/ghostty-os.md: - locale::ensure_locale is a no-op (setlocale/setenv are unsafe; GTK calls setlocale itself); setenv/unsetenv are not exposed. - passwd's Flatpak branch needs the termio pty and falls back to the sandbox entry for now. - FlatpakHostCommand's D-Bus path is untested (no portal here). Intentional fix: a leading '@' in NOTIFY_SOCKET is treated as an abstract socket. macOS/Windows/WASM modules are out of scope. Test Plan: - cargo test -p ghostty-os (88 tests) - cargo clippy -p ghostty-os --all-targets -- -D warnings
22 lines
502 B
Rust
22 lines
502 B
Rust
//! Command line argument iteration.
|
|
//!
|
|
//! The macOS NSProcessInfo-based iterator is skipped; on Linux this is the
|
|
//! standard process argument iterator (as `os_str`s so that non-UTF-8 args
|
|
//! don't panic).
|
|
|
|
/// Returns an iterator over the command line arguments.
|
|
pub fn iterator() -> std::env::ArgsOs {
|
|
std::env::args_os()
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn args() {
|
|
let mut iter = iterator();
|
|
assert!(!iter.next().unwrap().is_empty());
|
|
}
|
|
}
|