Skip to content

Commit ea48b29

Browse files
committed
Implement pipefail
1 parent 09d6b94 commit ea48b29

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/core.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,16 @@ impl ShellCore {
249249
self.set_foreground();
250250
self.data.set_layer_array("PIPESTATUS", &pipestatus, 0);
251251

252+
if self.options.query("pipefail") {
253+
let mut rightmost_nonzero = "0".to_string();
254+
for e in &pipestatus {
255+
if e != "0" {
256+
rightmost_nonzero = e.to_string();
257+
}
258+
}
259+
self.data.set_param("?", &rightmost_nonzero);
260+
}
261+
252262
if exclamation {
253263
self.flip_exit_status();
254264
}

0 commit comments

Comments
 (0)