Hi, The latest ash package (0.3.5-7) has a broken 'echo' builtin implementation. It should accept the -e and -n parameters, but it doesn't. That breaks many things for those who use ash as their /bin/sh - for example Linux compile process (makefile uses @echo -n ... to generate UTS_VERSION in include/linux/compile.h, which gets output as '-n #define UTS_VERSION ...'). The attached patch fixes the command to accept BOTH parameters. It parses the first args to echo searching for -n and/or -e. First argument starting with anything else than '-' or not being -n or -e causes echo to output the rest of commandline. marek
diff -U3 -r ash-0.3.5.orig/bltin/echo.c ash-0.3.5/bltin/echo.c
--- ash-0.3.5.orig/bltin/echo.c Thu Oct 21 14:55:29 1999
+++ ash-0.3.5/bltin/echo.c Thu Oct 21 14:51:34 1999
@@ -54,11 +54,36 @@
register char **ap;
register char *p;
register char c;
-
+ char nl = 1;
+
out1->flags &= ~OUTPUT_ERR;
ap = argv;
if (argc)
ap++;
+ /*
+ * Find all leading args starting with '-' and
+ * process them as our options. First arg starting
+ * with anything else than '-' stops the scan. The
+ * rest is displayed verbatim.
+ */
+ while ((p = *ap++) != NULL) {
+ if (*p == '-') {
+ switch (*(++p)) {
+ case 'e':
+ continue;
+ case 'n':
+ nl = 0;
+ continue;
+ default:
+ goto getout; /* ugly, but fast :) */
+ }
+ } else {
+ getout:
+ ap--;
+ break;
+ }
+ }
+
while ((p = *ap++) != NULL) {
while ((c = *p++) != '\0') {
if (c == '\\') {
@@ -90,7 +115,8 @@
if (*ap)
putchar(' ');
}
- putchar('\n');
+ if (nl)
+ putchar('\n');
fflush(stdout);
if (out1->flags & OUTPUT_ERR) {
out1->flags &= ~OUTPUT_ERR;
Attachment:
pgpHW3daT_X4B.pgp
Description: PGP signature