aboutsummaryrefslogtreecommitdiff
path: root/libbutl/command.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-06-01 19:51:17 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-06-03 12:23:29 +0300
commit70314b3303f712a0277b80b23bc3613744e6178e (patch)
treec20b0cddf91b2d2303feee440ec07c36fd5d0cd6 /libbutl/command.cxx
parentc0a025542988b63275fe1f9281020f4d4bec58a6 (diff)
Add builtin weight
Also invent the notion of external builtin (builtin_info::function is NULL).
Diffstat (limited to 'libbutl/command.cxx')
-rw-r--r--libbutl/command.cxx20
1 files changed, 10 insertions, 10 deletions
diff --git a/libbutl/command.cxx b/libbutl/command.cxx
index bb5287c..fadd617 100644
--- a/libbutl/command.cxx
+++ b/libbutl/command.cxx
@@ -227,9 +227,9 @@ namespace butl
msg.c_str ());
}
- builtin_function* bf (builtins.find (prog));
+ const builtin_info* bi (builtins.find (prog));
- if (bf != nullptr) // Execute the builtin.
+ if (bi != nullptr && bi->function != nullptr) // Execute the builtin.
{
if (callback)
{
@@ -259,17 +259,17 @@ namespace butl
uint8_t r; // Storage.
builtin_callbacks cb;
- builtin b (bf (r,
- args,
- nullfd /* stdin */,
- move (rd) /* stdout */,
- nullfd /* stderr */,
- cwd,
- cb));
+ builtin b (bi->function (r,
+ args,
+ nullfd /* stdin */,
+ move (rd) /* stdout */,
+ nullfd /* stderr */,
+ cwd,
+ cb));
return process_exit (b.wait ());
}
- else // Execute the program.
+ else // Execute the program.
{
// Strip the potential leading `^`, indicating that this is an external
// program rather than a builtin. Consider only simple paths and don't