implemented the 'builtin' and 'command' builtins

This commit is contained in:
2025-04-20 16:14:11 -04:00
parent 08e57e92fd
commit 3155db5565
3 changed files with 25 additions and 5 deletions

View File

@@ -25,6 +25,16 @@ pub fn alias(node: Node, io_stack: &mut IoStack, job: &mut JobBldr) -> ShResult<
write(stdout, alias_output.as_bytes())?; // Write it
} else {
for (arg,span) in argv {
if arg == "command" || arg == "builtin" {
return Err(
ShErr::full(
ShErrKind::ExecFail,
format!("alias: Cannot assign alias to reserved name '{arg}'"),
span
)
)
}
let Some((name,body)) = arg.split_once('=') else {
return Err(
ShErr::full(

View File

@@ -14,7 +14,7 @@ pub mod flowctl;
pub mod zoltraak;
pub mod shopt;
pub const BUILTINS: [&str;17] = [
pub const BUILTINS: [&str;19] = [
"echo",
"cd",
"export",
@@ -31,7 +31,9 @@ pub const BUILTINS: [&str;17] = [
"continue",
"exit",
"zoltraak",
"shopt"
"shopt",
"builtin",
"command"
];
/// Sets up a builtin command