Skip to content

Commit 5d9e753

Browse files
committed
sh: replace unwrap with expect
1 parent 0fd8793 commit 5d9e753

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

sh/shell/mod.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -778,17 +778,22 @@ impl Shell {
778778
if is_process_in_foreground() {
779779
// should never fail as child is a valid process id and
780780
// in the same session as the current shell
781-
let child_gpid = getpgid(child).unwrap();
781+
let child_gpid = getpgid(child)
782+
.expect("failed to get process id of child process");
782783
// should never fail as stdin is a valid file descriptor and
783784
// child gpid is valid and in the same session
784-
tcsetpgrp(io::stdin().as_raw_fd(), child_gpid).unwrap();
785-
kill(child, Some(Signal::SigCont)).unwrap();
785+
tcsetpgrp(io::stdin().as_raw_fd(), child_gpid)
786+
.expect("failed to set pipeline in foreground");
787+
kill(child, Some(Signal::SigCont))
788+
.expect("failed to start pipeline");
786789
pipeline_exit_status = self.wait_child_process(child)?;
787790
// should never fail
788-
tcsetpgrp(io::stdin().as_raw_fd(), getpgrp()).unwrap();
791+
tcsetpgrp(io::stdin().as_raw_fd(), getpgrp())
792+
.expect("failed to reset foreground process");
789793
break;
790794
} else {
791-
kill(child, Some(Signal::SigCont)).unwrap();
795+
kill(child, Some(Signal::SigCont))
796+
.expect("failed start pipeline");
792797
pipeline_exit_status = self.wait_child_process(child)?;
793798
break;
794799
}

0 commit comments

Comments
 (0)