summaryrefslogtreecommitdiff
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 b9ed0d7..253eb6d 100644
--- a/coreutils/Kbuild
+++ b/coreutils/Kbuild
@@ -30,6 +30,7 @@ lib-$(CONFIG_DOS2UNIX) += dos2unix.o
lib-$(CONFIG_DU) += du.o
lib-$(CONFIG_ECHO) += echo.o
lib-$(CONFIG_ASH) += echo.o # used by ash
+lib-$(CONFIG_HUSH) += echo.o # used by hush
lib-$(CONFIG_ENV) += env.o
lib-$(CONFIG_EXPR) += expr.o
lib-$(CONFIG_EXPAND) += expand.o
@@ -72,6 +73,8 @@ lib-$(CONFIG_TAIL) += tail.o
lib-$(CONFIG_TEE) += tee.o
lib-$(CONFIG_TEST) += test.o
lib-$(CONFIG_ASH) += test.o # used by ash
+lib-$(CONFIG_HUSH) += test.o # used by hush
+lib-$(CONFIG_MSH) += test.o # used by msh
lib-$(CONFIG_TOUCH) += touch.o
lib-$(CONFIG_TR) += tr.o
lib-$(CONFIG_TRUE) += true.o
diff --git a/coreutils/basename.c b/coreutils/basename.c
index d536a1b..ed23779 100644
--- a/coreutils/basename.c
+++ b/coreutils/basename.c
@@ -37,15 +37,16 @@ int basename_main(int argc, char **argv)
/* It should strip slash: /abc/def/ -> def */
s = bb_get_last_path_component_strip(*++argv);
+ m = strlen(s);
if (*++argv) {
n = strlen(*argv);
- m = strlen(s);
if ((m > n) && ((strcmp)(s+m-n, *argv) == 0)) {
- s[m-n] = '\0';
+ m -= n;
+ s[m] = '\0';
}
}
- puts(s);
-
- return fflush(stdout);
+ /* puts(s) will do, but we can do without stdio this way: */
+ s[m++] = '\n';
+ return full_write(STDOUT_FILENO, s, m) == m;
}
diff --git a/coreutils/echo.c b/coreutils/echo.c
index fd6c950..6e25db6 100644
--- a/coreutils/echo.c
+++ b/coreutils/echo.c
@@ -27,10 +27,8 @@
/* This is a NOFORK applet. Be very careful! */
-/* argc is unused, but removing it precludes compiler from
- * using call -> jump optimization */
+/* NB: can be used by shell even if not enabled as applet */
-int echo_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int echo_main(int argc ATTRIBUTE_UNUSED, char **argv)
{
const char *arg;