aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c46
-rw-r--r--shell/ash_test/ash-standalone/var_standalone1.right1
-rwxr-xr-xshell/ash_test/ash-standalone/var_standalone1.tests2
3 files changed, 16 insertions, 33 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 90680e849..f581b5bdf 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -36,16 +36,11 @@
36 36
37#define JOBS ENABLE_ASH_JOB_CONTROL 37#define JOBS ENABLE_ASH_JOB_CONTROL
38 38
39#if DEBUG
40# ifndef _GNU_SOURCE
41# define _GNU_SOURCE
42# endif
43#endif
44
45#include "busybox.h" /* for applet_names */ 39#include "busybox.h" /* for applet_names */
46#include <paths.h> 40#include <paths.h>
47#include <setjmp.h> 41#include <setjmp.h>
48#include <fnmatch.h> 42#include <fnmatch.h>
43#include <sys/times.h>
49 44
50#include "shell_common.h" 45#include "shell_common.h"
51#include "math.h" 46#include "math.h"
@@ -7251,6 +7246,7 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char **
7251#if ENABLE_FEATURE_SH_STANDALONE 7246#if ENABLE_FEATURE_SH_STANDALONE
7252 if (applet_no >= 0) { 7247 if (applet_no >= 0) {
7253 if (APPLET_IS_NOEXEC(applet_no)) { 7248 if (APPLET_IS_NOEXEC(applet_no)) {
7249 clearenv();
7254 while (*envp) 7250 while (*envp)
7255 putenv(*envp++); 7251 putenv(*envp++);
7256 run_applet_no_and_exit(applet_no, argv); 7252 run_applet_no_and_exit(applet_no, argv);
@@ -7310,7 +7306,7 @@ shellexec(char **argv, const char *path, int idx)
7310#endif 7306#endif
7311 7307
7312 clearredir(/*drop:*/ 1); 7308 clearredir(/*drop:*/ 1);
7313 envp = listvars(VEXPORT, VUNSET, 0); 7309 envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL);
7314 if (strchr(argv[0], '/') != NULL 7310 if (strchr(argv[0], '/') != NULL
7315#if ENABLE_FEATURE_SH_STANDALONE 7311#if ENABLE_FEATURE_SH_STANDALONE
7316 || (applet_no = find_applet_by_name(argv[0])) >= 0 7312 || (applet_no = find_applet_by_name(argv[0])) >= 0
@@ -12468,7 +12464,7 @@ unsetfunc(const char *name)
12468 struct tblentry *cmdp; 12464 struct tblentry *cmdp;
12469 12465
12470 cmdp = cmdlookup(name, 0); 12466 cmdp = cmdlookup(name, 0);
12471 if (cmdp!= NULL && cmdp->cmdtype == CMDFUNCTION) 12467 if (cmdp != NULL && cmdp->cmdtype == CMDFUNCTION)
12472 delete_cmd_entry(); 12468 delete_cmd_entry();
12473} 12469}
12474 12470
@@ -12485,7 +12481,7 @@ unsetcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
12485 int flag = 0; 12481 int flag = 0;
12486 int ret = 0; 12482 int ret = 0;
12487 12483
12488 while ((i = nextopt("vf")) != '\0') { 12484 while ((i = nextopt("vf")) != 0) {
12489 flag = i; 12485 flag = i;
12490 } 12486 }
12491 12487
@@ -12502,11 +12498,6 @@ unsetcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
12502 return ret & 1; 12498 return ret & 1;
12503} 12499}
12504 12500
12505
12506/* setmode.c */
12507
12508#include <sys/times.h>
12509
12510static const unsigned char timescmd_str[] ALIGN1 = { 12501static const unsigned char timescmd_str[] ALIGN1 = {
12511 ' ', offsetof(struct tms, tms_utime), 12502 ' ', offsetof(struct tms, tms_utime),
12512 '\n', offsetof(struct tms, tms_stime), 12503 '\n', offsetof(struct tms, tms_stime),
@@ -12514,11 +12505,10 @@ static const unsigned char timescmd_str[] ALIGN1 = {
12514 '\n', offsetof(struct tms, tms_cstime), 12505 '\n', offsetof(struct tms, tms_cstime),
12515 0 12506 0
12516}; 12507};
12517
12518static int FAST_FUNC 12508static int FAST_FUNC
12519timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) 12509timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
12520{ 12510{
12521 long clk_tck, s, t; 12511 unsigned long clk_tck, s, t;
12522 const unsigned char *p; 12512 const unsigned char *p;
12523 struct tms buf; 12513 struct tms buf;
12524 12514
@@ -12529,18 +12519,20 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
12529 do { 12519 do {
12530 t = *(clock_t *)(((char *) &buf) + p[1]); 12520 t = *(clock_t *)(((char *) &buf) + p[1]);
12531 s = t / clk_tck; 12521 s = t / clk_tck;
12532 out1fmt("%ldm%ld.%.3lds%c", 12522 t = t % clk_tck;
12533 s/60, s%60, 12523 out1fmt("%lum%lu.%03lus%c",
12534 ((t - s * clk_tck) * 1000) / clk_tck, 12524 s / 60, s % 60,
12525 (t * 1000) / clk_tck,
12535 p[0]); 12526 p[0]);
12536 } while (*(p += 2)); 12527 p += 2;
12528 } while (*p);
12537 12529
12538 return 0; 12530 return 0;
12539} 12531}
12540 12532
12541#if ENABLE_SH_MATH_SUPPORT 12533#if ENABLE_SH_MATH_SUPPORT
12542/* 12534/*
12543 * The let builtin. partial stolen from GNU Bash, the Bourne Again SHell. 12535 * The let builtin. Partially stolen from GNU Bash, the Bourne Again SHell.
12544 * Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc. 12536 * Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
12545 * 12537 *
12546 * Copyright (C) 2003 Vladimir Oleynik <dzo@simtreas.ru> 12538 * Copyright (C) 2003 Vladimir Oleynik <dzo@simtreas.ru>
@@ -12559,18 +12551,6 @@ letcmd(int argc UNUSED_PARAM, char **argv)
12559 12551
12560 return !i; 12552 return !i;
12561} 12553}
12562#endif /* SH_MATH_SUPPORT */
12563
12564
12565/* ============ miscbltin.c
12566 *
12567 * Miscellaneous builtins.
12568 */
12569
12570#undef rflag
12571
12572#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 1
12573typedef enum __rlimit_resource rlim_t;
12574#endif 12554#endif
12575 12555
12576/* 12556/*
diff --git a/shell/ash_test/ash-standalone/var_standalone1.right b/shell/ash_test/ash-standalone/var_standalone1.right
new file mode 100644
index 000000000..37457fd74
--- /dev/null
+++ b/shell/ash_test/ash-standalone/var_standalone1.right
@@ -0,0 +1 @@
Done: 1
diff --git a/shell/ash_test/ash-standalone/var_standalone1.tests b/shell/ash_test/ash-standalone/var_standalone1.tests
new file mode 100755
index 000000000..1e905ba75
--- /dev/null
+++ b/shell/ash_test/ash-standalone/var_standalone1.tests
@@ -0,0 +1,2 @@
1VAR=42 $THIS_SH -c 'unset VAR; env | grep ^VAR'
2echo Done: $?