Allow builtins to be executed as part of pipelines
Created by: huntergoldstein
Problem: Currently if we have a builtin to be run as part of a pipeline, we just take the job, reconstruct it, and run a sub-process such as ion -c builtin arg1 arg2
. This is problematic as it forces ion
to re-parse the given arguments which is inefficient and bug prone ( #454 (closed) ).
Solution: Manually manage running builtins as part of a pipeline by forking the current process and executing the builtin in the child process.
Changes introduced by this pull request:
- Replaced the use of
Command
inshell::pipe
withRefinedJob
; an enumeration that is either an external command or a builtin - Modified
shell::pipe::pipe
to fork and execute a builtin for theRefinedJob::Builtin
instance; behavior forRefinedJob::External
is roughly the same as before: build aCommand
, runspawn()
.
Drawbacks: The use of RawFd
everywhere might make #364 (closed) more difficult.
Fixes: Closes #379 (closed) ; Closes #454 (closed)
State: WIP; I want to make sure there are some regression tests in examples/
. Also this is a 500+- change so letting it sit for review would be good.
TODO:
-
Determine the redox equivalent for STDOUT_FILENO
et al -
Add a regression example in examples/
for piping to / from a builtin #