From c32e21fc01f3aa50e421a10606c454846a8c9aed Mon Sep 17 00:00:00 2001 From: Nikita Ofitserov Date: Wed, 27 May 2015 00:49:50 +0300 Subject: [PATCH 1/2] Add a test for the 'env -' case --- test/env.rs | 8 ++++++++ 1 file changed, 8 insertions(+) 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] From abd3e1e8e4951d07801f97292999ae1d2eb9d2a2 Mon Sep 17 00:00:00 2001 From: Nikita Ofitserov Date: Wed, 27 May 2015 00:51:14 +0300 Subject: [PATCH 2/2] Fix 'env -' case --- src/env/env.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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;