aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-02-23 21:11:02 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-02-23 21:11:02 +0000
commitf98dc4db7a7799ba4ab33934203b32368740e99f (patch)
tree5f32c17c0b845bbeb912d4b1ce3e940225b7d730
parent0dec6de38b721b4faae5567f8b4643df1055a175 (diff)
downloadbusybox-w32-f98dc4db7a7799ba4ab33934203b32368740e99f.tar.gz
busybox-w32-f98dc4db7a7799ba4ab33934203b32368740e99f.tar.bz2
busybox-w32-f98dc4db7a7799ba4ab33934203b32368740e99f.zip
ash: cleanup part 2.8
-rw-r--r--shell/ash.c132
1 files changed, 57 insertions, 75 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 1de4cb50b..a7e282377 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -155,8 +155,9 @@ static char gotsig[NSIG - 1];
155static char *arg0; /* value of $0 */ 155static char *arg0; /* value of $0 */
156 156
157 157
158/* ============ Interrupts / exceptions 158/* ============ Interrupts / exceptions */
159 * 159
160/*
160 * We enclose jmp_buf in a structure so that we can declare pointers to 161 * We enclose jmp_buf in a structure so that we can declare pointers to
161 * jump locations. The global variable handler contains the location to 162 * jump locations. The global variable handler contains the location to
162 * jump to when an exception occurs, and the global variable exception 163 * jump to when an exception occurs, and the global variable exception
@@ -8045,14 +8046,46 @@ localcmd(int argc, char **argv)
8045 return 0; 8046 return 0;
8046} 8047}
8047 8048
8049static int
8050falsecmd(int argc, char **argv)
8051{
8052 return 1;
8053}
8054
8055static int
8056truecmd(int argc, char **argv)
8057{
8058 return 0;
8059}
8060
8061static int
8062execcmd(int argc, char **argv)
8063{
8064 if (argc > 1) {
8065 iflag = 0; /* exit on error */
8066 mflag = 0;
8067 optschanged();
8068 shellexec(argv + 1, pathval(), 0);
8069 }
8070 return 0;
8071}
8072
8073/*
8074 * The return command.
8075 */
8076static int
8077returncmd(int argc, char **argv)
8078{
8079 /*
8080 * If called outside a function, do what ksh does;
8081 * skip the rest of the file.
8082 */
8083 evalskip = funcnest ? SKIPFUNC : SKIPFILE;
8084 return argv[1] ? number(argv[1]) : exitstatus;
8085}
8086
8048/* Forward declarations for builtintab[] */ 8087/* Forward declarations for builtintab[] */
8049#if JOBS
8050static int fg_bgcmd(int, char **);
8051#endif
8052static int breakcmd(int, char **); 8088static int breakcmd(int, char **);
8053#if ENABLE_ASH_CMDCMD
8054static int commandcmd(int, char **);
8055#endif
8056static int dotcmd(int, char **); 8089static int dotcmd(int, char **);
8057static int evalcmd(int, char **); 8090static int evalcmd(int, char **);
8058#if ENABLE_ASH_BUILTIN_ECHO 8091#if ENABLE_ASH_BUILTIN_ECHO
@@ -8061,39 +8094,22 @@ static int echocmd(int, char **);
8061#if ENABLE_ASH_BUILTIN_TEST 8094#if ENABLE_ASH_BUILTIN_TEST
8062static int testcmd(int, char **); 8095static int testcmd(int, char **);
8063#endif 8096#endif
8064static int execcmd(int, char **);
8065static int exitcmd(int, char **); 8097static int exitcmd(int, char **);
8066static int exportcmd(int, char **); 8098static int exportcmd(int, char **);
8067static int falsecmd(int, char **);
8068#if ENABLE_ASH_GETOPTS 8099#if ENABLE_ASH_GETOPTS
8069static int getoptscmd(int, char **); 8100static int getoptscmd(int, char **);
8070#endif 8101#endif
8071static int hashcmd(int, char **);
8072#if !ENABLE_FEATURE_SH_EXTRA_QUIET
8073static int helpcmd(int argc, char **argv);
8074#endif
8075#if JOBS
8076static int jobscmd(int, char **);
8077#endif
8078#if ENABLE_ASH_MATH_SUPPORT 8102#if ENABLE_ASH_MATH_SUPPORT
8079static int letcmd(int, char **); 8103static int letcmd(int, char **);
8080#endif 8104#endif
8081static int pwdcmd(int, char **);
8082static int readcmd(int, char **); 8105static int readcmd(int, char **);
8083static int returncmd(int, char **);
8084static int setcmd(int, char **); 8106static int setcmd(int, char **);
8085static int shiftcmd(int, char **); 8107static int shiftcmd(int, char **);
8086static int timescmd(int, char **); 8108static int timescmd(int, char **);
8087static int trapcmd(int, char **); 8109static int trapcmd(int, char **);
8088static int truecmd(int, char **);
8089static int typecmd(int, char **);
8090static int umaskcmd(int, char **); 8110static int umaskcmd(int, char **);
8091static int unsetcmd(int, char **); 8111static int unsetcmd(int, char **);
8092static int waitcmd(int, char **);
8093static int ulimitcmd(int, char **); 8112static int ulimitcmd(int, char **);
8094#if JOBS
8095static int killcmd(int, char **);
8096#endif
8097 8113
8098#define BUILTIN_NOSPEC "0" 8114#define BUILTIN_NOSPEC "0"
8099#define BUILTIN_SPECIAL "1" 8115#define BUILTIN_SPECIAL "1"
@@ -8505,9 +8521,10 @@ prehash(union node *n)
8505} 8521}
8506 8522
8507 8523
8508/* 8524/* ============ Builtin commands
8509 * Builtin commands. Builtin commands whose functions are closely 8525 *
8510 * tied to evaluation are implemented here. 8526 * Builtin commands whose functions are closely tied to evaluation
8527 * are implemented here.
8511 */ 8528 */
8512 8529
8513/* 8530/*
@@ -8520,7 +8537,6 @@ prehash(union node *n)
8520 * be an error to break out of more loops than exist, but it isn't 8537 * be an error to break out of more loops than exist, but it isn't
8521 * in the standard shell so we don't make it one here. 8538 * in the standard shell so we don't make it one here.
8522 */ 8539 */
8523
8524static int 8540static int
8525breakcmd(int argc, char **argv) 8541breakcmd(int argc, char **argv)
8526{ 8542{
@@ -8531,50 +8547,12 @@ breakcmd(int argc, char **argv)
8531 if (n > loopnest) 8547 if (n > loopnest)
8532 n = loopnest; 8548 n = loopnest;
8533 if (n > 0) { 8549 if (n > 0) {
8534 evalskip = (**argv == 'c')? SKIPCONT : SKIPBREAK; 8550 evalskip = (**argv == 'c') ? SKIPCONT : SKIPBREAK;
8535 skipcount = n; 8551 skipcount = n;
8536 } 8552 }
8537 return 0; 8553 return 0;
8538} 8554}
8539 8555
8540/*
8541 * The return command.
8542 */
8543static int
8544returncmd(int argc, char **argv)
8545{
8546 /*
8547 * If called outside a function, do what ksh does;
8548 * skip the rest of the file.
8549 */
8550 evalskip = funcnest ? SKIPFUNC : SKIPFILE;
8551 return argv[1] ? number(argv[1]) : exitstatus;
8552}
8553
8554static int
8555falsecmd(int argc, char **argv)
8556{
8557 return 1;
8558}
8559
8560static int
8561truecmd(int argc, char **argv)
8562{
8563 return 0;
8564}
8565
8566static int
8567execcmd(int argc, char **argv)
8568{
8569 if (argc > 1) {
8570 iflag = 0; /* exit on error */
8571 mflag = 0;
8572 optschanged();
8573 shellexec(argv + 1, pathval(), 0);
8574 }
8575 return 0;
8576}
8577
8578 8556
8579/* ============ input.c 8557/* ============ input.c
8580 * 8558 *
@@ -10876,8 +10854,7 @@ parseheredoc(void)
10876 10854
10877 10855
10878/* 10856/*
10879 * called by editline -- any expansions to the prompt 10857 * called by editline -- any expansions to the prompt should be added here.
10880 * should be added here.
10881 */ 10858 */
10882#if ENABLE_ASH_EXPAND_PRMT 10859#if ENABLE_ASH_EXPAND_PRMT
10883static const char * 10860static const char *
@@ -10900,7 +10877,6 @@ expandstr(const char *ps)
10900} 10877}
10901#endif 10878#endif
10902 10879
10903
10904/* 10880/*
10905 * Execute a command or commands contained in a string. 10881 * Execute a command or commands contained in a string.
10906 */ 10882 */
@@ -11207,10 +11183,16 @@ find_command(char *name, struct cmdentry *entry, int act, const char *path)
11207 11183
11208 /* If %builtin not in path, check for builtin next */ 11184 /* If %builtin not in path, check for builtin next */
11209 bcmd = find_builtin(name); 11185 bcmd = find_builtin(name);
11210 if (bcmd && (IS_BUILTIN_REGULAR(bcmd) || ( 11186 if (bcmd) {
11211 act & DO_ALTPATH ? !(act & DO_ALTBLTIN) : builtinloc <= 0 11187 if (IS_BUILTIN_REGULAR(bcmd))
11212 ))) 11188 goto builtin_success;
11213 goto builtin_success; 11189 if (act & DO_ALTPATH) {
11190 if (!(act & DO_ALTBLTIN))
11191 goto builtin_success;
11192 } else if (builtinloc <= 0) {
11193 goto builtin_success;
11194 }
11195 }
11214 11196
11215 /* We have to search path. */ 11197 /* We have to search path. */
11216 prev = -1; /* where to start */ 11198 prev = -1; /* where to start */