From bbd0a26012a746c5c82fa3c198d579fc670ffd23 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Thu, 9 May 2019 18:58:35 -0500 Subject: [PATCH] env: minor fixes and commentary polish --- src/env/env.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/env/env.rs b/src/env/env.rs index 1790cb75b..d16d0fc97 100644 --- a/src/env/env.rs +++ b/src/env/env.rs @@ -64,7 +64,7 @@ pub fn uumain(args: Vec) -> i32 { "null", "end each output line with a 0 byte rather than newline (only valid when printing the environment)", ) - .optopt("f", "file", "read and sets variables from the file (prior to sets/unsets)", "FILE") + .optopt("f", "file", "read and set variables from an \".env\"-style configuration file (prior to any unset and/or set)", "PATH") .optopt("u", "unset", "remove variable from the environment", "NAME"); let mut opts = Box::new(Options { @@ -120,7 +120,7 @@ pub fn uumain(args: Vec) -> i32 { let var = iter.next(); match var { - None => println!("{}: this option requires an argument: {}", NAME, opt), + None => eprintln!("{}: this option requires an argument: {}", NAME, opt), Some(s) => opts.files.push(s.to_owned()), } } @@ -159,7 +159,7 @@ pub fn uumain(args: Vec) -> i32 { let var = iter.next(); match var { - None => println!("{}: this option requires an argument: {}", NAME, opt), + None => eprintln!("{}: this option requires an argument: {}", NAME, opt), Some(s) => opts.files.push(s.to_owned()), } } @@ -222,6 +222,8 @@ pub fn uumain(args: Vec) -> i32 { } } + // NOTE: config files are parsed using an INI parser b/c it's available and compatible with ".env"-style files + // ... * but support for actual INI files, although working, is not intended, nor claimed for file in &opts.files { let conf = if file == "-" { let stdin = stdin(); @@ -237,7 +239,7 @@ pub fn uumain(args: Vec) -> i32 { return 1; } }; - for (_, prop) in &conf { + for (_, prop) in &conf { // ignore all INI section lines (treat them as comments) for (key, value) in prop { env::set_var(key, value); }