diff --git a/src/env/env.rs b/src/env/env.rs index 90618a415..9486d7ed6 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -86,8 +86,8 @@ pub fn uumain(args: Vec) -> i32 { } } else if opt.starts_with("--") { match opt.as_ref() { - "--help" => { core_opts.parse(vec![String::from("--help")]); return 0; } - "--version" => { core_opts.parse(vec![String::from("--version")]); return 0; } + "--help" => { core_opts.parse(vec![String::new(), String::from("--help")]); return 0; } + "--version" => { core_opts.parse(vec![String::new(), String::from("--version")]); return 0; } "--ignore-environment" => opts.ignore_env = true, "--null" => opts.null = true, diff --git a/tests/test_env.rs b/tests/test_env.rs index ea618db58..6646d5af7 100644 --- a/tests/test_env.rs +++ b/tests/test_env.rs @@ -1,6 +1,16 @@ use common::util::*; +#[test] +fn test_env_help() { + assert!(new_ucmd!().arg("--help").succeeds().no_stderr().stdout.contains("Options:")); +} + +#[test] +fn test_env_version() { + assert!(new_ucmd!().arg("--version").succeeds().no_stderr().stdout.contains(util_name!())); +} + #[test] fn test_single_name_value_pair() { let out = new_ucmd!()