Files
sausage/spikes/s2-shell/userland/src/main.rs
T
surma 9e9cde5241 spikes: six v3 spikes (V8 harness, WASI shell, git, builder, http hook, esbuild)
Throwaway prototypes for Sausage v3. Plan and decisions:
~/research/sausage-v3/PLAN.md. Results and evidence: the spike READMEs.
2026-11-06 14:03:20 +00:00

25 lines
995 B
Rust

//! Dispatches uutils 0.12 commands after libc adopts the process working directory.
fn main() {
// wasi-libc starts at / and does not consume wasi:cli/environment.initial-cwd.
std::env::set_current_dir(std::env::var("S2_CWD").expect("host supplies cwd"))
.expect("process working directory exists");
let argv0 = std::env::args().next().expect("host supplies argv0");
let name = std::path::Path::new(&argv0)
.file_name()
.unwrap()
.to_str()
.unwrap();
uucore::locale::setup_localization(name).expect("utility supplies localization");
let args = uucore::args_os();
let code = match name {
"cat" => uu_cat::uumain(args),
"tr" => uu_tr::uumain(args),
"ls" => uu_ls::uumain(args),
"wc" => uu_wc::uumain(args),
"yes" => uu_yes::uumain(args),
"head" => uu_head::uumain(args),
_ => unreachable!("fixture supplies the six uutils aliases"),
};
std::process::exit(code);
}