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
526cc8846c
commit
4c1e68c9f4
1 changed files with 16 additions and 12 deletions
28
src/uu/env/src/env.rs
vendored
28
src/uu/env/src/env.rs
vendored
|
@ -344,18 +344,7 @@ impl EnvAppData {
|
|||
program: vec![],
|
||||
};
|
||||
|
||||
// change directory
|
||||
if let Some(d) = opts.running_directory {
|
||||
match env::set_current_dir(d) {
|
||||
Ok(()) => d,
|
||||
Err(error) => {
|
||||
return Err(USimpleError::new(
|
||||
125,
|
||||
format!("cannot change directory to {}: {error}", d.quote()),
|
||||
));
|
||||
}
|
||||
};
|
||||
}
|
||||
apply_change_directory(&opts)?;
|
||||
|
||||
let mut begin_prog_opts = false;
|
||||
if let Some(mut iter) = matches.get_many::<OsString>("vars") {
|
||||
|
@ -494,6 +483,21 @@ impl EnvAppData {
|
|||
}
|
||||
}
|
||||
|
||||
fn apply_change_directory(opts: &Options<'_>) -> Result<(), Box<dyn UError>> {
|
||||
if let Some(d) = opts.running_directory {
|
||||
match env::set_current_dir(d) {
|
||||
Ok(()) => d,
|
||||
Err(error) => {
|
||||
return Err(USimpleError::new(
|
||||
125,
|
||||
format!("cannot change directory to {}: {error}", d.quote()),
|
||||
));
|
||||
}
|
||||
};
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn apply_specified_env_vars(opts: &Options<'_>) {
|
||||
// set specified env vars
|
||||
for (name, val) in &opts.sets {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue