summaryrefslogtreecommitdiffhomepage
path: root/shell/ash.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-06-19 17:50:44 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-06-19 17:50:44 +0200
commit020465218ccff1195a47a890037db37d0395c9d9 (patch)
tree491ffc11553f9de9b91c890f82dc0668c44660e8 /shell/ash.c
parente329089c62ed813e97344f8c61d7dc34221fd5ee (diff)
parent8cd9f343e74ca65f36c42a44e845716ba5411663 (diff)
Merge branch 'master' of git+ssh://vda@busybox.net/var/lib/git/busybox
Diffstat (limited to 'shell/ash.c')
-rw-r--r--shell/ash.c46
1 files changed, 13 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 @@
#define JOBS ENABLE_ASH_JOB_CONTROL
-#if DEBUG
-# ifndef _GNU_SOURCE
-# define _GNU_SOURCE
-# endif
-#endif
-
#include "busybox.h" /* for applet_names */
#include <paths.h>
#include <setjmp.h>
#include <fnmatch.h>
+#include <sys/times.h>
#include "shell_common.h"
#include "math.h"
@@ -7251,6 +7246,7 @@ tryexec(IF_FEATURE_SH_STANDALONE(int applet_no,) char *cmd, char **argv, char **
#if ENABLE_FEATURE_SH_STANDALONE
if (applet_no >= 0) {
if (APPLET_IS_NOEXEC(applet_no)) {
+ clearenv();
while (*envp)
putenv(*envp++);
run_applet_no_and_exit(applet_no, argv);
@@ -7310,7 +7306,7 @@ shellexec(char **argv, const char *path, int idx)
#endif
clearredir(/*drop:*/ 1);
- envp = listvars(VEXPORT, VUNSET, 0);
+ envp = listvars(VEXPORT, VUNSET, /*end:*/ NULL);
if (strchr(argv[0], '/') != NULL
#if ENABLE_FEATURE_SH_STANDALONE
|| (applet_no = find_applet_by_name(argv[0])) >= 0
@@ -12468,7 +12464,7 @@ unsetfunc(const char *name)
struct tblentry *cmdp;
cmdp = cmdlookup(name, 0);
- if (cmdp!= NULL && cmdp->cmdtype == CMDFUNCTION)
+ if (cmdp != NULL && cmdp->cmdtype == CMDFUNCTION)
delete_cmd_entry();
}
@@ -12485,7 +12481,7 @@ unsetcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
int flag = 0;
int ret = 0;
- while ((i = nextopt("vf")) != '\0') {
+ while ((i = nextopt("vf")) != 0) {
flag = i;
}
@@ -12502,11 +12498,6 @@ unsetcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
return ret & 1;
}
-
-/* setmode.c */
-
-#include <sys/times.h>
-
static const unsigned char timescmd_str[] ALIGN1 = {
' ', offsetof(struct tms, tms_utime),
'\n', offsetof(struct tms, tms_stime),
@@ -12514,11 +12505,10 @@ static const unsigned char timescmd_str[] ALIGN1 = {
'\n', offsetof(struct tms, tms_cstime),
0
};
-
static int FAST_FUNC
timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
- long clk_tck, s, t;
+ unsigned long clk_tck, s, t;
const unsigned char *p;
struct tms buf;
@@ -12529,18 +12519,20 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
do {
t = *(clock_t *)(((char *) &buf) + p[1]);
s = t / clk_tck;
- out1fmt("%ldm%ld.%.3lds%c",
- s/60, s%60,
- ((t - s * clk_tck) * 1000) / clk_tck,
+ t = t % clk_tck;
+ out1fmt("%lum%lu.%03lus%c",
+ s / 60, s % 60,
+ (t * 1000) / clk_tck,
p[0]);
- } while (*(p += 2));
+ p += 2;
+ } while (*p);
return 0;
}
#if ENABLE_SH_MATH_SUPPORT
/*
- * The let builtin. partial stolen from GNU Bash, the Bourne Again SHell.
+ * The let builtin. Partially stolen from GNU Bash, the Bourne Again SHell.
* Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
*
* Copyright (C) 2003 Vladimir Oleynik <dzo@simtreas.ru>
@@ -12559,18 +12551,6 @@ letcmd(int argc UNUSED_PARAM, char **argv)
return !i;
}
-#endif /* SH_MATH_SUPPORT */
-
-
-/* ============ miscbltin.c
- *
- * Miscellaneous builtins.
- */
-
-#undef rflag
-
-#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ < 1
-typedef enum __rlimit_resource rlim_t;
#endif
/*