aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/Kbuild3
-rw-r--r--coreutils/basename.c11
-rw-r--r--coreutils/echo.c4
3 files changed, 10 insertions, 8 deletions
diff --git a/coreutils/Kbuild b/coreutils/Kbuild
index b9ed0d79e..253eb6da8 100644
--- a/coreutils/Kbuild
+++ b/coreutils/Kbuild
@@ -30,6 +30,7 @@ lib-$(CONFIG_DOS2UNIX) += dos2unix.o
30lib-$(CONFIG_DU) += du.o 30lib-$(CONFIG_DU) += du.o
31lib-$(CONFIG_ECHO) += echo.o 31lib-$(CONFIG_ECHO) += echo.o
32lib-$(CONFIG_ASH) += echo.o # used by ash 32lib-$(CONFIG_ASH) += echo.o # used by ash
33lib-$(CONFIG_HUSH) += echo.o # used by hush
33lib-$(CONFIG_ENV) += env.o 34lib-$(CONFIG_ENV) += env.o
34lib-$(CONFIG_EXPR) += expr.o 35lib-$(CONFIG_EXPR) += expr.o
35lib-$(CONFIG_EXPAND) += expand.o 36lib-$(CONFIG_EXPAND) += expand.o
@@ -72,6 +73,8 @@ lib-$(CONFIG_TAIL) += tail.o
72lib-$(CONFIG_TEE) += tee.o 73lib-$(CONFIG_TEE) += tee.o
73lib-$(CONFIG_TEST) += test.o 74lib-$(CONFIG_TEST) += test.o
74lib-$(CONFIG_ASH) += test.o # used by ash 75lib-$(CONFIG_ASH) += test.o # used by ash
76lib-$(CONFIG_HUSH) += test.o # used by hush
77lib-$(CONFIG_MSH) += test.o # used by msh
75lib-$(CONFIG_TOUCH) += touch.o 78lib-$(CONFIG_TOUCH) += touch.o
76lib-$(CONFIG_TR) += tr.o 79lib-$(CONFIG_TR) += tr.o
77lib-$(CONFIG_TRUE) += true.o 80lib-$(CONFIG_TRUE) += true.o
diff --git a/coreutils/basename.c b/coreutils/basename.c
index d536a1bf3..ed2377948 100644
--- a/coreutils/basename.c
+++ b/coreutils/basename.c
@@ -37,15 +37,16 @@ int basename_main(int argc, char **argv)
37 /* It should strip slash: /abc/def/ -> def */ 37 /* It should strip slash: /abc/def/ -> def */
38 s = bb_get_last_path_component_strip(*++argv); 38 s = bb_get_last_path_component_strip(*++argv);
39 39
40 m = strlen(s);
40 if (*++argv) { 41 if (*++argv) {
41 n = strlen(*argv); 42 n = strlen(*argv);
42 m = strlen(s);
43 if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) { 43 if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {
44 s[m-n] = '\0'; 44 m -= n;
45 s[m] = '\0';
45 } 46 }
46 } 47 }
47 48
48 puts(s); 49 /* puts(s) will do, but we can do without stdio this way: */
49 50 s[m++] = '\n';
50 return fflush(stdout); 51 return full_write(STDOUT_FILENO, s, m) == m;
51} 52}
diff --git a/coreutils/echo.c b/coreutils/echo.c
index fd6c950ea..6e25db62c 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -27,10 +27,8 @@
27 27
28/* This is a NOFORK applet. Be very careful! */ 28/* This is a NOFORK applet. Be very careful! */
29 29
30/* argc is unused, but removing it precludes compiler from 30/* NB: can be used by shell even if not enabled as applet */
31 * using call -> jump optimization */
32 31
33int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
34int echo_main(int argc ATTRIBUTE_UNUSED, char **argv) 32int echo_main(int argc ATTRIBUTE_UNUSED, char **argv)
35{ 33{
36 const char *arg; 34 const char *arg;