Throwaway prototypes for Sausage v3. Plan and decisions: ~/research/sausage-v3/PLAN.md. Results and evidence: the spike READMEs.
25 lines
995 B
Rust
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);
|
|
}
|