diff --git a/mkmain.rs b/mkmain.rs index 9270b5390..f065ea8b2 100644 --- a/mkmain.rs +++ b/mkmain.rs @@ -13,7 +13,7 @@ use uu_@UTIL_CRATE@::uumain; fn main() { uucore::panic::install_sigpipe_hook(); - let code = uumain(std::env::args().collect()); + let code = uumain(uucore::args().collect()); // Since stdout is line-buffered by default, we need to ensure any pending // writes are flushed before exiting. Ideally, this should be enforced by // each utility. diff --git a/src/uucore/Cargo.toml b/src/uucore/Cargo.toml index 3a5a09a66..c4fda8c07 100644 --- a/src/uucore/Cargo.toml +++ b/src/uucore/Cargo.toml @@ -10,6 +10,7 @@ failure_derive = { version = "0.1.1", optional = true } time = { version = "0.1.40", optional = true } data-encoding = { version = "^2.1", optional = true } libc = { version = "0.2.42", optional = true } +wild = "1.0.1" [target.'cfg(target_os = "redox")'.dependencies] termion = "1.5" diff --git a/src/uucore/lib.rs b/src/uucore/lib.rs index bfa111564..8cc7494fe 100644 --- a/src/uucore/lib.rs +++ b/src/uucore/lib.rs @@ -1,3 +1,13 @@ +extern crate wild; + +pub fn args() -> Box> { + Box::new( wild::args().map(|s| s.into_string().unwrap()) ) +} + +pub fn args_os() -> Box> { + Box::new( wild::args() ) +} + #[cfg(feature = "libc")] pub extern crate libc; #[cfg(feature = "winapi")] diff --git a/src/uutils/uutils.rs b/src/uutils/uutils.rs index 59a2d7a40..7ee823dad 100644 --- a/src/uutils/uutils.rs +++ b/src/uutils/uutils.rs @@ -13,7 +13,6 @@ include!(concat!(env!("OUT_DIR"), "/uutils_crates.rs")); use std::collections::hash_map::HashMap; use std::path::Path; -use std::env; use std::io::Write; extern crate uucore; @@ -40,7 +39,7 @@ fn main() { uucore::panic::install_sigpipe_hook(); let umap = util_map(); - let mut args: Vec = env::args().collect(); + let mut args: Vec = uucore::args().collect(); // try binary name as util name. let args0 = args[0].clone();