1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #1089 from flyrry/fix_env

fix --help and --version
This commit is contained in:
Alex Lyon 2017-11-15 13:06:31 -08:00 committed by GitHub
commit f7b97dc3d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

4
src/env/env.rs vendored
View file

@ -86,8 +86,8 @@ pub fn uumain(args: Vec<String>) -> i32 {
} }
} else if opt.starts_with("--") { } else if opt.starts_with("--") {
match opt.as_ref() { match opt.as_ref() {
"--help" => { core_opts.parse(vec![String::from("--help")]); return 0; } "--help" => { core_opts.parse(vec![String::new(), String::from("--help")]); return 0; }
"--version" => { core_opts.parse(vec![String::from("--version")]); return 0; } "--version" => { core_opts.parse(vec![String::new(), String::from("--version")]); return 0; }
"--ignore-environment" => opts.ignore_env = true, "--ignore-environment" => opts.ignore_env = true,
"--null" => opts.null = true, "--null" => opts.null = true,

View file

@ -1,6 +1,16 @@
use common::util::*; 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] #[test]
fn test_single_name_value_pair() { fn test_single_name_value_pair() {
let out = new_ucmd!() let out = new_ucmd!()