Don't report error when cwd is not exists. (#5590)

* only set cwd for child process if cwd exists, and avoid showing error when pwd is not exists

* better comment text

Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
This commit is contained in:
WindSoilder 2022-05-20 20:03:03 +08:00 committed by GitHub
parent 0d06b6259f
commit 6efd1bcb3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -220,10 +220,7 @@ pub fn eval_source(
}
};
if let Err(err) = engine_state.merge_delta(delta, Some(stack), &cwd) {
let working_set = StateWorkingSet::new(engine_state);
report_error(&working_set, &err);
}
let _ = engine_state.merge_delta(delta, Some(stack), &cwd);
match eval_block(engine_state, stack, &block, input, false, false) {
Ok(mut pipeline_data) => {

View File

@ -1,6 +1,6 @@
use std::collections::HashMap;
use std::io::{BufRead, BufReader, Write};
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::process::{Command as CommandSys, Stdio};
use std::sync::atomic::Ordering;
use std::sync::mpsc;
@ -339,7 +339,10 @@ impl ExternalCommand {
self.create_command(d)?
};
// do not try to set current directory if cwd does not exist
if Path::new(&d).exists() {
process.current_dir(d);
}
process
} else {
return Err(ShellError::GenericError(