diff --git a/src/env/env.rs b/src/env/env.rs index a4d8c4417..89fc38718 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -116,7 +116,7 @@ pub fn uumain(args: Vec) -> i32 { } } } else if opt.starts_with("-") { - if opt.len() == 0 { + if opt.len() == 1 { // implies -i and stop parsing opts wait_cmd = true; opts.ignore_env = true; diff --git a/test/env.rs b/test/env.rs index a513d0f68..9be3165a8 100644 --- a/test/env.rs +++ b/test/env.rs @@ -35,6 +35,14 @@ fn test_ignore_environment() { let out = str::from_utf8(&po.stdout[..]).unwrap(); assert_eq!(out, ""); + + let po = Command::new(PROGNAME) + .arg("-") + .output() + .unwrap_or_else(|err| panic!("{}", err)); + + let out = str::from_utf8(&po.stdout[..]).unwrap(); + assert_eq!(out, ""); } #[test]