From 059578953d9c9d4a47e39f3432277155e8659bd0 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Wed, 30 Jan 2013 18:49:19 +0100 Subject: [PATCH] Upgrading echo Change-Id: Idaa5da742b3cc9a1ee2f5c03f10e0627690556fa --- bin/Makefile | 2 +- bin/echo/Makefile | 6 +++ bin/echo/echo.1 | 68 +++++++++++++++++++++++++++++++++ bin/echo/echo.c | 83 +++++++++++++++++++++++++++++++++++++++++ man/man1/Makefile | 2 +- man/man1/echo.1 | 68 --------------------------------- releasetools/nbsd_ports | 1 + 7 files changed, 160 insertions(+), 70 deletions(-) create mode 100644 bin/echo/Makefile create mode 100644 bin/echo/echo.1 create mode 100644 bin/echo/echo.c delete mode 100644 man/man1/echo.1 diff --git a/bin/Makefile b/bin/Makefile index 01654c543..218137b64 100644 --- a/bin/Makefile +++ b/bin/Makefile @@ -1,7 +1,7 @@ # $NetBSD: Makefile,v 1.22 2007/12/31 15:31:24 ad Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 -SUBDIR= cat date ed \ +SUBDIR= cat date echo ed \ mkdir pax rm rmdir test .include diff --git a/bin/echo/Makefile b/bin/echo/Makefile new file mode 100644 index 000000000..10de729ee --- /dev/null +++ b/bin/echo/Makefile @@ -0,0 +1,6 @@ +# $NetBSD: Makefile,v 1.8 1997/07/20 22:36:53 christos Exp $ +# @(#)Makefile 8.1 (Berkeley) 5/31/93 + +PROG= echo + +.include diff --git a/bin/echo/echo.1 b/bin/echo/echo.1 new file mode 100644 index 000000000..acf128d02 --- /dev/null +++ b/bin/echo/echo.1 @@ -0,0 +1,68 @@ +.\" $NetBSD: echo.1,v 1.13 2003/08/07 09:05:12 agc Exp $ +.\" +.\" Copyright (c) 1990, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the Institute of Electrical and Electronics Engineers, Inc. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)echo.1 8.1 (Berkeley) 7/22/93 +.\" +.Dd July 22, 1993 +.Dt ECHO 1 +.Os +.Sh NAME +.Nm echo +.Nd write arguments to the standard output +.Sh SYNOPSIS +.Nm +.Op Fl n +.Op Ar string ... +.Sh DESCRIPTION +The +.Nm +utility writes any specified operands, separated by single blank (`` '') +characters and followed by a newline (``\en'') character, to the standard +output. +.Pp +The following option is available: +.Bl -tag -width flag +.It Fl n +Do not print the trailing newline character. +.El +.Sh EXIT STATUS +The +.Nm +utility exits 0 on success, and \*[Gt]0 if an error occurs. +.Sh SEE ALSO +.Xr printf 1 +.Sh STANDARDS +The +.Nm +utility is expected to be +.St -p1003.2 +compatible. diff --git a/bin/echo/echo.c b/bin/echo/echo.c new file mode 100644 index 000000000..81f24ac1c --- /dev/null +++ b/bin/echo/echo.c @@ -0,0 +1,83 @@ +/* $NetBSD: echo.c,v 1.18 2008/09/18 05:42:08 dholland Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#ifndef lint +__COPYRIGHT( +"@(#) Copyright (c) 1989, 1993\ + The Regents of the University of California. All rights reserved."); +#endif /* not lint */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)echo.c 8.1 (Berkeley) 5/31/93"; +#else +__RCSID("$NetBSD: echo.c,v 1.18 2008/09/18 05:42:08 dholland Exp $"); +#endif +#endif /* not lint */ + +#include +#include +#include +#include + +int main(int, char *[]); + +/* ARGSUSED */ +int +main(int argc, char *argv[]) +{ + int nflag; + + setprogname(argv[0]); + (void)setlocale(LC_ALL, ""); + + /* This utility may NOT do getopt(3) option parsing. */ + if (*++argv && !strcmp(*argv, "-n")) { + ++argv; + nflag = 1; + } + else + nflag = 0; + + while (*argv) { + (void)printf("%s", *argv); + if (*++argv) + (void)putchar(' '); + } + if (nflag == 0) + (void)putchar('\n'); + fflush(stdout); + if (ferror(stdout)) + exit(1); + exit(0); + /* NOTREACHED */ +} diff --git a/man/man1/Makefile b/man/man1/Makefile index d8de1ce83..6578906ee 100644 --- a/man/man1/Makefile +++ b/man/man1/Makefile @@ -3,7 +3,7 @@ MAN= ash.1 at.1 banner.1 basename.1 \ chmod.1 cmp.1 comm.1 compress.1 \ cp.1 crc.1 crontab.1 dd.1 \ df.1 dhrystone.1 dosdir.1 dosread.1 doswrite.1 \ - dumpcore.1 echo.1 eject.1 \ + dumpcore.1 eject.1 \ env.1 expand.1 expr.1 factor.1 \ finger.1 flexdoc.1 fold.1 format.1 fortune.1 \ fsck.mfs.1 head.1 host.1 hostaddr.1 ifdef.1 \ diff --git a/man/man1/echo.1 b/man/man1/echo.1 deleted file mode 100644 index ead97c062..000000000 --- a/man/man1/echo.1 +++ /dev/null @@ -1,68 +0,0 @@ -.TH ECHO 1 -.SH NAME \" Copyright (C) 1989 by Kenneth Almquist. -echo \- produce message in a shell script -.SH SYNOPSIS -.B echo -[ -.B -n -| -.B -e -] -.I args... -.SH DESCRIPTION -.I Echo -prints its arguments on the standard output, separated by spaces. -Unless the -.B -n -option is present, a newline is output following the arguments. -The -.B -e -option causes -.I echo -to treat the escape sequences specially, as described in the following -paragraph. -Only one of the options -.B -n -and -.B -e -may be given. -.PP -If any of the following sequences of characters is encountered during -output, the sequence is not output. Instead, the specified action is -performed: -.de i -.IP "\\fB\\$1\\fR" 5 -.. -.i \eb -A backspace character is output. -.i \ec -Subsequent output is suppressed. This is normally used at the end of the -last argument to suppress the trailing newline that -.I echo -would otherwise output. -.i \ef -Output a form feed. -.i \en -Output a newline character. -.i \er -Output a carriage return. -.i \et -Output a (horizontal) tab character. -.i \ev -Output a vertical tab. -.i \e0\fIdigits\fR -Output the character whose value is given by zero to three digits. -If there are zero digits, a nul character is output. -.i \e\e -Output a backslash. -.SH HINTS -Remember that backslash is special to the shell and needs to be escaped. -To output a message to standard error, say -.sp -.ti +1i -echo message >&2 -.SH BUGS -The octal character escape mechanism (\e0\fIdigits\fR) differs from the -C language mechanism. -.SH AUTHOR -Kenneth Almquist. diff --git a/releasetools/nbsd_ports b/releasetools/nbsd_ports index 2b78850f3..e236e32f5 100644 --- a/releasetools/nbsd_ports +++ b/releasetools/nbsd_ports @@ -8,6 +8,7 @@ # netbsdpath: path in BSD source tree (starting from src/) 2012/01/16 18:47:57,bin/cat 2011/08/27 12:55:09,bin/date +2012/10/17 12:00:00,bin/echo 2012/01/16 18:47:57,bin/ed 2012/10/17 12:00:00,bin/Makefile 2012/10/17 12:00:00,bin/Makefile.inc -- 2.44.0