mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
replace comment with extracted function
This commit is contained in:
parent
4c1e68c9f4
commit
59df0b8fb8
1 changed files with 19 additions and 15 deletions
34
src/uu/env/src/env.rs
vendored
34
src/uu/env/src/env.rs
vendored
|
@ -388,21 +388,7 @@ impl EnvAppData {
|
||||||
// load .env-style config file prior to those given on the command-line
|
// load .env-style config file prior to those given on the command-line
|
||||||
load_config_file(&mut opts)?;
|
load_config_file(&mut opts)?;
|
||||||
|
|
||||||
// unset specified env vars
|
apply_unset_env_vars(&opts)?;
|
||||||
for name in &opts.unsets {
|
|
||||||
let native_name = NativeStr::new(name);
|
|
||||||
if name.is_empty()
|
|
||||||
|| native_name.contains(&'\0').unwrap()
|
|
||||||
|| native_name.contains(&'=').unwrap()
|
|
||||||
{
|
|
||||||
return Err(USimpleError::new(
|
|
||||||
125,
|
|
||||||
format!("cannot unset {}: Invalid argument", name.quote()),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
env::remove_var(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
apply_specified_env_vars(&opts);
|
apply_specified_env_vars(&opts);
|
||||||
|
|
||||||
|
@ -483,6 +469,24 @@ impl EnvAppData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn apply_unset_env_vars(opts: &Options<'_>) -> Result<(), Box<dyn UError>> {
|
||||||
|
for name in &opts.unsets {
|
||||||
|
let native_name = NativeStr::new(name);
|
||||||
|
if name.is_empty()
|
||||||
|
|| native_name.contains(&'\0').unwrap()
|
||||||
|
|| native_name.contains(&'=').unwrap()
|
||||||
|
{
|
||||||
|
return Err(USimpleError::new(
|
||||||
|
125,
|
||||||
|
format!("cannot unset {}: Invalid argument", name.quote()),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
env::remove_var(name);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn apply_change_directory(opts: &Options<'_>) -> Result<(), Box<dyn UError>> {
|
fn apply_change_directory(opts: &Options<'_>) -> Result<(), Box<dyn UError>> {
|
||||||
if let Some(d) = opts.running_directory {
|
if let Some(d) = opts.running_directory {
|
||||||
match env::set_current_dir(d) {
|
match env::set_current_dir(d) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue