X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=shell%2Fash.c;h=713898a9f598459fc59f37168df9f522dd0e1c63;hb=f94637959902b54b2a1c44e3608fa77158856005;hp=708ab21fbd2a309f1792566733967d3eaa9352e3;hpb=47b1838957c1f303077f802f2dd6ed2e5d57be5f;p=oweals%2Fbusybox.git diff --git a/shell/ash.c b/shell/ash.c index 708ab21fb..713898a9f 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -44,11 +44,12 @@ */ - #define IFS_BROKEN #define PROFILE 0 +#include "busybox.h" + #ifdef DEBUG #define _GNU_SOURCE #endif @@ -58,7 +59,6 @@ #include #include #include -#include #include #include @@ -77,12 +77,10 @@ #include #include #include -#include +/*#include */ #include #include - -#include "busybox.h" #include "pwd_.h" #ifdef CONFIG_ASH_JOB_CONTROL @@ -1227,6 +1225,9 @@ static int evalcmd(int, char **); #ifdef CONFIG_ASH_BUILTIN_ECHO static int echocmd(int, char **); #endif +#ifdef CONFIG_ASH_BUILTIN_TEST +static int testcmd(int, char **); +#endif static int execcmd(int, char **); static int exitcmd(int, char **); static int exportcmd(int, char **); @@ -1288,10 +1289,15 @@ struct builtincmd { #define COMMANDCMD (builtincmd + 5 + \ - ENABLE_ASH_ALIAS + ENABLE_ASH_JOB_CONTROL) + 2 * ENABLE_ASH_BUILTIN_TEST + \ + ENABLE_ASH_ALIAS + \ + ENABLE_ASH_JOB_CONTROL) #define EXECCMD (builtincmd + 7 + \ - ENABLE_ASH_CMDCMD + ENABLE_ASH_ALIAS + \ - ENABLE_ASH_BUILTIN_ECHO + ENABLE_ASH_JOB_CONTROL) + 2 * ENABLE_ASH_BUILTIN_TEST + \ + ENABLE_ASH_ALIAS + \ + ENABLE_ASH_JOB_CONTROL + \ + ENABLE_ASH_CMDCMD + \ + ENABLE_ASH_BUILTIN_ECHO) #define BUILTIN_NOSPEC "0" #define BUILTIN_SPECIAL "1" @@ -1309,6 +1315,10 @@ struct builtincmd { static const struct builtincmd builtincmd[] = { { BUILTIN_SPEC_REG ".", dotcmd }, { BUILTIN_SPEC_REG ":", truecmd }, +#ifdef CONFIG_ASH_BUILTIN_TEST + { BUILTIN_REGULAR "[", testcmd }, + { BUILTIN_REGULAR "[[", testcmd }, +#endif #ifdef CONFIG_ASH_ALIAS { BUILTIN_REG_ASSG "alias", aliascmd }, #endif @@ -1355,6 +1365,9 @@ static const struct builtincmd builtincmd[] = { { BUILTIN_SPEC_REG "set", setcmd }, { BUILTIN_SPEC_REG "source", dotcmd }, { BUILTIN_SPEC_REG "shift", shiftcmd }, +#ifdef CONFIG_ASH_BUILTIN_TEST + { BUILTIN_REGULAR "test", testcmd }, +#endif { BUILTIN_SPEC_REG "times", timescmd }, { BUILTIN_SPEC_REG "trap", trapcmd }, { BUILTIN_REGULAR "true", truecmd }, @@ -7147,8 +7160,8 @@ forkchild(struct job *jp, union node *n, int mode) ignoresig(SIGQUIT); if (jp->nprocs == 0) { close(0); - if (open(_PATH_DEVNULL, O_RDONLY) != 0) - sh_error("Can't open %s", _PATH_DEVNULL); + if (open(bb_dev_null, O_RDONLY) != 0) + sh_error("Can't open %s", bb_dev_null); } } if (!oldlvl && iflag) { @@ -8145,6 +8158,15 @@ echocmd(int argc, char **argv) return bb_echo(argc, argv); } #endif + +#ifdef CONFIG_ASH_BUILTIN_TEST +static int +testcmd(int argc, char **argv) +{ + return bb_test(argc, argv); +} +#endif + /* memalloc.c */ /* @@ -8764,7 +8786,7 @@ procargs(int argc, char **argv) xminusc = minusc; if (*xargv == NULL) { if (xminusc) - sh_error("-c requires an argument"); + sh_error(bb_msg_requires_arg, "-c"); sflag = 1; } if (iflag == 2 && sflag == 1 && isatty(0) && isatty(1))