summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRory Dudley2024-02-28 16:05:45 -0700
committerRory Dudley2024-02-28 16:05:45 -0700
commit2d2d5af3553b732237937549dc9b6df28b7c00cb (patch)
tree4780127fbbd5431470e5e2c0764848cad4984f88
parent5890deb68e54838559c5d32c70d65e033e33d682 (diff)
downloaddwarvish-2d2d5af3553b732237937549dc9b6df28b7c00cb.tar.gz
Fix && behavior regressionrmerr
Introduce a switch to break from recite() if the forked process returns a non-zero exit code. The one except to this, is when using semicolons, then we do not care if the previous command failed.
-rw-r--r--src/recite.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/recite.rs b/src/recite.rs
index f21a905..f75cd61 100644
--- a/src/recite.rs
+++ b/src/recite.rs
@@ -22,7 +22,7 @@ use std::sync::{Arc, Mutex};
/// * `Quiet` - Fork the called process into the background (`&`)
/// * `And` - Run the next command only if this one succeeds (`&&`)
/// * `String` - String commands together on a single line (`;`)
-#[derive(Debug)]
+#[derive(Debug, PartialEq, Eq)]
enum Meter {
None, // No meter
Couplet, // Pipe the output of this command into the next
@@ -376,19 +376,19 @@ impl Poem {
}
// Incant the verse, based on its meter
- match verse.meter {
+ let status = match verse.meter {
Meter::None => Meter::incant_none(verse, &mut out)?,
Meter::Couplet => Meter::incant_couplet(verse, &mut out)?,
Meter::Quiet => Meter::incant_quiet(verse, &mut out, &mut pids)?,
Meter::And => Meter::incant_and(verse, &mut out)?,
- Meter::String => match Meter::incant_string(verse, &mut out) {
- Ok(_) => 0,
- Err(e) => {
- eprintln!("dwvsh: {}", e.to_string().to_lowercase());
- 1
- }
- },
+ Meter::String => Meter::incant_string(verse, &mut out)?,
};
+
+ // Don't continue reciting if there was an error, unless the meter
+ // is String (indicating that errors should be ignored)
+ if verse.meter != Meter::String && status != 0 {
+ break;
+ }
}
// If we've successfully exited the loop, then all verse's were