summaryrefslogtreecommitdiffstats
path: root/src/poem/elements/verse
diff options
context:
space:
mode:
authorRory Dudley2024-06-21 15:40:49 -0400
committerRory Dudley2024-06-21 15:40:49 -0400
commite23e4a036008a6f3a3356d48434615a05dcc17e0 (patch)
treea93bfcf486db01af7efb51dd15835c3ca31bad53 /src/poem/elements/verse
parentfedd4c31b0d1c6d036b1105a74b6e6a1f135f2b4 (diff)
downloaddwarvish-e23e4a036008a6f3a3356d48434615a05dcc17e0.tar.gz
Fix capturing output for internal poems
Sometime when the switch to the new built-in command system was happening, we lost the logic to force the capture the output of STDOUT, mainly used for running internal poems (i.e. 'ls `ls`'). This patch adds a new field to the Environment struct, called fc (force capture). It gets set to true before running internal poems, and unset afterwards. Finally, some checks were added to the incant!() macro to properly handle STDOUT when fc is set.
Diffstat (limited to 'src/poem/elements/verse')
-rw-r--r--src/poem/elements/verse/logic.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/poem/elements/verse/logic.rs b/src/poem/elements/verse/logic.rs
index c1d3d62..f5efdee 100644
--- a/src/poem/elements/verse/logic.rs
+++ b/src/poem/elements/verse/logic.rs
@@ -28,6 +28,11 @@ macro_rules! incant {
$command.stderr(Stdio::piped());
}
+ // Capture stdout if (f)orce (c)apture is set
+ if $env.fc {
+ $command.stdout(Stdio::piped());
+ }
+
// Detach the process group, if in the [Rune::Quiet] meter
if $self.meter == Rune::Quiet {
$command.process_group(0);
@@ -59,6 +64,9 @@ macro_rules! incant {
$out.append(&mut output.stdout);
err.append(&mut output.stderr);
}
+ if $env.fc {
+ $out.append(&mut output.stdout);
+ }
}
Rune::Couplet => {
output = child.wait_with_output()?;
@@ -210,7 +218,7 @@ macro_rules! incant {
}
err.clear();
- if $self.meter != Rune::Couplet {
+ if $self.meter != Rune::Couplet && $env.fc != true {
$out.clear();
}