From e23e4a036008a6f3a3356d48434615a05dcc17e0 Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Fri, 21 Jun 2024 15:40:49 -0400 Subject: 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. --- src/poem/recite.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/poem/recite.rs') diff --git a/src/poem/recite.rs b/src/poem/recite.rs index b27ef75..7ceecca 100644 --- a/src/poem/recite.rs +++ b/src/poem/recite.rs @@ -98,7 +98,9 @@ impl Reciteable for Poem { Some(poem) => poem, None => break, // TODO: Return an error }; + env.fc = true; let mut out = poem.recite(env)?; + env.fc = false; match out.last() { Some(last) => { if *last == b'\n' { -- cgit v1.2.3