From 7e874c2bb6de9d92c41c920902c72901ba6c02d7 Mon Sep 17 00:00:00 2001
From: Coleman McFarland <coleman.mcfarland@gmail.com>
Date: Sat, 2 Dec 2017 20:43:54 -0800
Subject: [PATCH] Allow builtins in aliases

During a pipeline execution, aliases are expanded and split into an
Array. The first item in this array should be either a builtin or a
command. If it is a builtin, assign the Job.builtin fn pointer field.
Otherwise, assume the alias refers to a command. Fixes #622
---
 src/shell/mod.rs | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/shell/mod.rs b/src/shell/mod.rs
index 42e20684..9722f401 100644
--- a/src/shell/mod.rs
+++ b/src/shell/mod.rs
@@ -240,7 +240,11 @@ impl<'a> Shell {
                         .map(String::from)
                         .chain(pipeline.items[job_no].job.args.drain().skip(1))
                         .collect::<Array>();
-                    pipeline.items[job_no].job.command = new_args[0].clone().into();
+                    if let Some(builtin) = BUILTINS.get(&new_args[0]) {
+                        pipeline.items[job_no].job.builtin = Some(builtin.main);
+                    } else {
+                        pipeline.items[job_no].job.command = new_args[0].clone().into();
+                    }
                     pipeline.items[job_no].job.args = new_args;
                 }
             }
-- 
GitLab