Skip to content

Commit

Permalink
report full cmds in error to give more context
Browse files Browse the repository at this point in the history
fix #71
  • Loading branch information
tao-guo committed Oct 1, 2024
1 parent c8a4248 commit b6aeab4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl Cmds {
.map_err(|e| new_cmd_io_error(&e, &full_cmds, &file, line))?;
}
let child = cmd
.spawn(current_dir, with_output)
.spawn(full_cmds.clone(), current_dir, with_output)
.map_err(|e| new_cmd_io_error(&e, &full_cmds, &file, line))?;
children.push(child);
}
Expand Down Expand Up @@ -392,20 +392,24 @@ impl Cmd {
(self.args.len() > args.len(), self)
}

fn spawn(mut self, current_dir: &mut PathBuf, with_output: bool) -> Result<CmdChild> {
fn spawn(
mut self,
full_cmds: String,
current_dir: &mut PathBuf,
with_output: bool,
) -> Result<CmdChild> {
let arg0 = self.arg0();
if arg0 == CD_CMD {
self.run_cd_cmd(current_dir, &self.file, self.line)?;
Ok(CmdChild::new(
CmdChildHandle::SyncFn,
self.cmd_str(),
full_cmds,
self.file,
self.line,
self.stdout_logging,
self.stderr_logging,
))
} else if self.in_cmd_map {
let cmd_str = self.cmd_str();
let pipe_out = self.stdout_logging.is_none();
let mut env = CmdEnv {
args: self
Expand Down Expand Up @@ -442,7 +446,7 @@ impl Cmd {
let handle = thread::Builder::new().spawn(move || internal_cmd(&mut env))?;
Ok(CmdChild::new(
CmdChildHandle::Thread(handle),
cmd_str,
full_cmds,
self.file,
self.line,
self.stdout_logging,
Expand All @@ -452,7 +456,7 @@ impl Cmd {
internal_cmd(&mut env)?;
Ok(CmdChild::new(
CmdChildHandle::SyncFn,
cmd_str,
full_cmds,
self.file,
self.line,
self.stdout_logging,
Expand Down Expand Up @@ -486,7 +490,7 @@ impl Cmd {
let child = cmd.spawn()?;
Ok(CmdChild::new(
CmdChildHandle::Proc(child),
self.cmd_str(),
full_cmds,
self.file,
self.line,
self.stdout_logging,
Expand Down

0 comments on commit b6aeab4

Please sign in to comment.