diff options
author | Nate Lawson <njl@FreeBSD.org> | 2002-11-13 01:39:02 +0000 |
---|---|---|
committer | Nate Lawson <njl@FreeBSD.org> | 2002-11-13 01:39:02 +0000 |
commit | ef3e71dac35bf73e0d8572057112e5dcdf5dc7c4 (patch) | |
tree | 2748e2342bcd52cb0e42a1b49b56f45b5d1042d1 /bin/echo | |
parent | 0ac1a67828095eaf03d2eadc68fdd5585138c4a7 (diff) | |
download | src-ef3e71dac35bf73e0d8572057112e5dcdf5dc7c4.tar.gz src-ef3e71dac35bf73e0d8572057112e5dcdf5dc7c4.zip |
Notes
Diffstat (limited to 'bin/echo')
-rw-r--r-- | bin/echo/echo.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/bin/echo/echo.c b/bin/echo/echo.c index 6a7a2b14f6f5..b4aeb62ee131 100644 --- a/bin/echo/echo.c +++ b/bin/echo/echo.c @@ -45,8 +45,7 @@ static char sccsid[] = "@(#)echo.c 8.1 (Berkeley) 5/31/93"; #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); -#include <stdio.h> -#include <stdlib.h> +#include <unistd.h> #include <string.h> /* ARGSUSED */ @@ -64,6 +63,9 @@ main(int argc __unused, char *argv[]) nflag = 0; while (argv[0] != NULL) { + size_t len; + + len = strlen(argv[0]); /* * If the next argument is NULL then this is this @@ -71,23 +73,20 @@ main(int argc __unused, char *argv[]) * for a trailing \c. */ if (argv[1] == NULL) { - size_t len; - - len = strlen(argv[0]); /* is there room for a '\c' and is there one? */ if (len >= 2 && argv[0][len - 2] == '\\' && argv[0][len - 1] == 'c') { /* chop it and set the no-newline flag. */ - argv[0][len - 2] = '\0'; + len -= 2; nflag = 1; } } - (void)printf("%s", argv[0]); + write(STDOUT_FILENO, argv[0], len); if (*++argv) - putchar(' '); + write(STDOUT_FILENO, " ", 1); } if (!nflag) - putchar('\n'); + write(STDOUT_FILENO, "\n", 1); return 0; } |