|
|
|
|
|
|
|
|
|
| |
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.
|
|
Previously, built-in commands were fairly primitive, merely outputting
STDOUT and STDERR with the print! macros. However, we need them to
behave like normal programs, that is:
- Acknowledge their verse's meter (forking, piping, etc.),
- Ability to capture STDOUT and STDERR (>, 2>),
- and Affect the currently running environment.
For these reasons, the anthology was reworked, and now contains the
Anthology struct, which mimics both std::process::{Child, Command}.
The AnthologyStdin helper struct was also created, for built-ins to
take input on STDIN, though no built-in is currently using it.
Each built-ins' incant functions were updated to return a
std::process::Output. It contains output from STDOUT, output from
STDERR, and the exit code of the "process".
A fix was also implemented for aliases, where the STDOUT and STDERR
vectors were not being copied to the newly constructed verse.
Notes:
There is some cleanup that needs to happen on this patch. For one, the
spellcheck function is no longer being used, so there is a generic OS
error if the program cannot be found in the $PATH. Also,
anthology::lookup gets called twice, which shouldn't need to happen.
|