Skip to content

Allow builtins to be executed as part of pipelines

Michael Aaron Murphy requested to merge huntergoldstein:pipeline_builtins into master

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 in shell::pipe with RefinedJob; an enumeration that is either an external command or a builtin
  • Modified shell::pipe::pipe to fork and execute a builtin for the RefinedJob::Builtin instance; behavior for RefinedJob::External is roughly the same as before: build a Command, run spawn().

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 #

Merge request reports