mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 15:22:38 +00:00
Merge pull request #1374 from rivy/fix.env-polish
env: minor fixes and commentary polish
This commit is contained in:
commit
e1cf3a42d5
1 changed files with 6 additions and 4 deletions
10
src/env/env.rs
vendored
10
src/env/env.rs
vendored
|
@ -64,7 +64,7 @@ pub fn uumain(args: Vec<String>) -> 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<String>) -> 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<String>) -> 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<String>) -> 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<String>) -> 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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue