summaryrefslogtreecommitdiff
path: root/package/sash
diff options
context:
space:
mode:
authormirabilos <tg@mirbsd.org>2017-11-18 12:41:10 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2017-11-19 09:09:27 +0100
commit864f03819dd5108af31f9a2bc4315dfe58b0c8cb (patch)
tree46852c1e4eba0dcba1a93c67857a4f3079a75f81 /package/sash
parent69229e524cde4412eb111180f15e073cc00366d9 (diff)
implement mksh-like “builtin” command
Signed-off-by: mirabilos <tg@mirbsd.org>
Diffstat (limited to 'package/sash')
-rw-r--r--package/sash/src/sash.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/package/sash/src/sash.c b/package/sash/src/sash.c
index 463d70740..3f2ce7de5 100644
--- a/package/sash/src/sash.c
+++ b/package/sash/src/sash.c
@@ -20,7 +20,9 @@
#include <sys/time.h>
#include <sys/wait.h>
-static char version[] = "OpenADK";
+static const char version[] = "OpenADK";
+static const char enoent_msg[] = "Bad command or file name";
+static const char unkerr_msg[] = "Unknown error!";
extern int intflag;
@@ -430,9 +432,14 @@ command(cmd, do_history)
* Now look for the command in the builtin table, and execute
* the command if found.
*/
- if (!command_in_path(argv[0]))
- if (trybuiltin(argc, argv))
- return;
+ if (!strcmp(argv[0], "builtin")) {
+ --argc;
+ ++argv;
+ if (!*argv || !trybuiltin(argc, argv))
+ fprintf(stderr, "%s: %s\n", argv[-1], enoent_msg);
+ return;
+ } else if (!command_in_path(argv[0]) && trybuiltin(argc, argv))
+ return;
/*
* Not found, run the program along the PATH list.
@@ -556,9 +563,6 @@ trybuiltin(argc, argv)
return TRUE;
}
-static const char enoent_msg[] = "Bad command or file name";
-static const char unkerr_msg[] = "Unknown error!";
-
/*
* Execute the specified command.
*/