diff options
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | builtins.c | 71 | ||||
-rw-r--r-- | parse.c | 6 | ||||
-rw-r--r-- | sh.h | 1 | ||||
-rw-r--r-- | type.c | 4 | ||||
-rw-r--r-- | unspecified.c | 8 |
6 files changed, 85 insertions, 9 deletions
@@ -12,7 +12,7 @@ SOURCES=alias.c bg.c builtins.c cd.c command.c fc.c fg.c getopts.c \ ulimit.c umask.c wait.c \ dot.c eval.c exec.c exit.c export.c readonly.c shift.c times.c trap.c \ unset.c \ - interactive.c parse.c init.c getopt.c \ + interactive.c parse.c init.c getopt.c unspecified.c \ shed.c shed_commands.c shed_edit.c shed_insert.c shed_io.c shed_move.c shed_non_vi.c HEADERS=sh.h shed.h OBJECTS=alias.o bg.o builtins.o cd.o command.o fc.o fg.o getopts.o \ @@ -20,7 +20,7 @@ OBJECTS=alias.o bg.o builtins.o cd.o command.o fc.o fg.o getopts.o \ ulimit.o umask.o wait.o \ dot.o eval.o exec.o exit.o export.o readonly.o shift.o times.o trap.o \ unset.o \ - interactive.o parse.o init.o getopt.o \ + interactive.o parse.o init.o getopt.o unspecified.o \ shed.o shed_commands.o shed_edit.o shed_insert.o shed_io.o shed_move.o shed_non_vi.o \ sh.tab.o sh.yy.o BUILTINS=alias bg cd command fc fg getopts jobs newgrp read \ @@ -85,6 +85,8 @@ int umask_main(int argc, char *argv[]); int unalias_main(int argc, char *argv[]); int wait_main(int argc, char *argv[]); +int unspecified_main(int argc, char *argv[]); + #ifndef EXTRA_BUILTINS #define EXTRA_BUILTINS /* empty */ #endif @@ -113,6 +115,60 @@ static struct builtin regular_builtins[] = { { 0, 0 }, }; +static struct builtin unspecified_builtins[] = { + { "alloc", unspecified_main }, + { "autoload", unspecified_main }, + { "bind", unspecified_main }, + { "bindkey", unspecified_main }, + { "builtin", unspecified_main }, + { "bye", unspecified_main }, + { "caller", unspecified_main }, + { "cap", unspecified_main }, + { "chdir", unspecified_main }, + { "clone", unspecified_main }, + { "copmarguments", unspecified_main }, + { "compcall", unspecified_main }, + { "compctl", unspecified_main }, + { "compdescribe", unspecified_main }, + { "compfiles", unspecified_main }, + { "compgen", unspecified_main }, + { "compgroups", unspecified_main }, + { "complete", unspecified_main }, + { "compquote", unspecified_main }, + { "comptags", unspecified_main }, + { "comptry", unspecified_main }, + { "compvalues", unspecified_main }, + { "declare", unspecified_main }, + { "dirs", unspecified_main }, + { "disable", unspecified_main }, + { "disown", unspecified_main }, + { "dosh", unspecified_main }, + { "echotc", unspecified_main }, + { "echoti", unspecified_main }, + { "help", unspecified_main }, + { "history", unspecified_main }, + { "hist", unspecified_main }, + { "let", unspecified_main }, + { "local", unspecified_main }, + { "login", unspecified_main }, + { "logout", unspecified_main }, + { "map", unspecified_main }, + { "mapfile", unspecified_main }, + { "popd", unspecified_main }, + { "print", unspecified_main }, + { "pushed", unspecified_main }, + { "readarray", unspecified_main }, + { "repeat", unspecified_main }, + { "savehistory", unspecified_main }, + { "source", unspecified_main }, + { "shopt", unspecified_main }, + { "stop", unspecified_main }, + { "suspend", unspecified_main }, + { "typeset", unspecified_main }, + { "whence", unspecified_main }, + { 0, 0 }, +}; + static int (*sh_getbuiltin(const char *util, struct builtin *bi))(int argc, char *argv[]) { for (int i = 0; bi[i].name; i++) { @@ -140,11 +196,15 @@ int sh_builtin(int argc, char *argv[]) int (*m)(int, char *[]) = sh_getbuiltin(util, special_builtins); if (m == NULL) { m = sh_getbuiltin(util, regular_builtins); - if (m == NULL) { - return 1; - } } + if (m == NULL) { + m = sh_getbuiltin(util, unspecified_builtins); + } + + if (m == NULL) { + return 1; + } optind = 0; return m(argc, argv); @@ -171,6 +231,11 @@ int sh_is_regular_builtin(const char *util) return is_builtin(util, regular_builtins); } +int sh_is_unspecified(const char *util) +{ + return is_builtin(util, unspecified_builtins); +} + #define main true_main #include "true/true.c" #undef main @@ -152,12 +152,10 @@ int sh_simple_command(struct simple_command *c) return sh_builtin(c->argc, c->argv); } - /* - if (sh_is_unspecified_utility(path)) { - fprintf(stderr, "sh: %s has unspecified behavior, doing nothing\n", path); + if (sh_is_unspecified(path)) { + return sh_builtin(c->argc, c->argv); return 1; } - */ /* if (sh_is_function(path)) { @@ -52,6 +52,7 @@ int sh_geto(char *option); int sh_interactive(void); int sh_is_special_builtin(const char *util); +int sh_is_unspecified(const char *util); int sh_is_regular_builtin(const char *util); int (*sh_get_builtin(const char *util))(int argc, char *argv[]); int sh_builtin(int argc, char *argv[]); @@ -25,6 +25,10 @@ int type_main(int argc, char **argv) continue; } + if (sh_is_unspecified(argv[i])) { + printf("%s: allowable POSIX extension (not implemented)\n", argv[i]); + } + /* if (sh_is_function(argv[i])) { printf("%s: function\n", argv[i]); diff --git a/unspecified.c b/unspecified.c new file mode 100644 index 0000000..28c1647 --- /dev/null +++ b/unspecified.c @@ -0,0 +1,8 @@ +#include <stdio.h> + +int unspecified_main(int argc, char *argv[]) +{ + (void)argc; + fprintf(stderr, "sh: %s is an extension allowed by POSIX but not implemented in this shell\n", argv[0]); + return 1; +} |