fix: preserve non-UTF-8 bytes in OS, config and CLI layers

Zig treats paths, arguments and environment values as byte slices; the
port converted them lossily in many places. Now (final-Z1.md):
- argv, env (incl. present non-UTF-8 values), HOME, PATH lookup,
  passwd, resources dir, TMPDIR, cgroup, config path canonicalization,
  +validate-config, +list-themes and Zig-string escapes (\xFF) keep raw
  bytes. String-based config values carry bytes via ghostty_os::osbytes,
  a bijective escape (noncharacter U+FDD0 + byte) that leaves all valid
  UTF-8 - including Nerd Font private-use icons - unchanged.
- os/file rlimit fallbacks exist on all targets.
- i18n locale canonicalization is an exact port of libintl's tables
  (e.g. pa-Guru -> pa_IN).
- New ghostty-build-info crate is the single source of version, channel,
  commit and build mode for all consumers.

Test Plan:
- cargo test -p ghostty-os -p ghostty-config -p ghostty-cli
  (incl. randomized osbytes round-trip property tests)
This commit is contained in:
ddidderr committed 2026-10-12 08:14:02 +02:00
1 parent 3f3f6680a5
commit 8519f1ba1b
32 files changed
+1464 -333

No files matched your search

+16 -9
View File
@@ -1408,14 +1408,13 @@ fn error_name(e: &ghostty_config::config::Error) -> String {
pub fn resolve_auto_theme_path() -> Result<String, Error> {
let main_cfg_path = ghostty_config::file_load::preferred_default_file_path()
.map_err(|e| Error::Other(e.to_string()))?;
let base_dir = std::path::Path::new(&main_cfg_path)
let main_cfg_path = ghostty_os::osbytes::config_str_to_path(&main_cfg_path);
let base_dir = main_cfg_path
.parent()
.ok_or_else(|| Error::Other("BadPathName".to_string()))?;
Ok(base_dir
.join("auto")
.join("theme.ghostty")
.to_string_lossy()
.into_owned())
Ok(ghostty_os::osbytes::path_to_config_string(
&base_dir.join("auto").join("theme.ghostty"),
))
}
/// `writeAutoThemeFile`.
@@ -1424,10 +1423,14 @@ pub fn write_auto_theme_file(path: Option<&str>, theme_name: &str) -> Result<(),
Some(p) => p.to_string(),
None => resolve_auto_theme_path()?,
};
if let Some(dir) = std::path::Path::new(&auto_path).parent() {
let auto_path = ghostty_os::osbytes::config_str_to_path(&auto_path);
if let Some(dir) = auto_path.parent() {
std::fs::create_dir_all(dir)?;
}
std::fs::write(&auto_path, format!("theme = {theme_name}\n"))?;
std::fs::write(
&auto_path,
ghostty_os::osbytes::config_str_to_bytes(&format!("theme = {theme_name}\n")),
)?;
Ok(())
}
@@ -1734,7 +1737,11 @@ fn run_loop(app: &mut Preview) -> Result<(), Error> {
match effect {
Effect::Copy(text) => {
let out = terminal.backend_mut();
write!(out, "\x1b]52;c;{}\x1b\\", base64(text.as_bytes()))?;
write!(
out,
"\x1b]52;c;{}\x1b\\",
base64(&ghostty_os::osbytes::config_str_to_bytes(&text))
)?;
out.flush()?;
}
}