summaryrefslogtreecommitdiff
path: root/src/echo.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-09-25 12:58:50 +0000
committerJim Meyering <jim@meyering.net>1997-09-25 12:58:50 +0000
commitb7bfc2d2a212be9d9431ae94bbf0f0bf23196f2c (patch)
tree2f0c5cd60da6568cd801c20ed5032b72113c936d /src/echo.c
parent9177f974dae07d5862a31cbcb064ebd5b3001f5d (diff)
downloadcoreutils-b7bfc2d2a212be9d9431ae94bbf0f0bf23196f2c.tar.xz
Make echo conform to POSIX. By default, don't
interpret backslash escape sequences. [V9_DEFAULT]: Don't #define. (usage): Document -e option. (main): Recognize options iff POSIXLY_CORRECT is not set. From Bruno Haible.
Diffstat (limited to 'src/echo.c')
-rw-r--r--src/echo.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/echo.c b/src/echo.c
index df8a79a50..47464acd9 100644
--- a/src/echo.c
+++ b/src/echo.c
@@ -45,7 +45,7 @@ on System V systems with the -E option.
/* If defined, interpret backslash escapes unless -E is given.
V9_ECHO must also be defined. */
-#define V9_DEFAULT
+/* #define V9_DEFAULT */
#if defined (V9_ECHO)
# if defined (V9_DEFAULT)
@@ -73,8 +73,9 @@ usage (int status)
Echo the STRING(s) to standard output.\n\
\n\
-n do not output the trailing newline\n\
- -e (unused)\n\
- -E disable interpolation of some sequences in STRINGs\n\
+ -e enable interpretation of the backslash-escaped characters\n\
+ listed below\n\
+ -E disable interpretation of those sequences in STRINGs\n\
--help display this help and exit (should be alone)\n\
--version output version information and exit (should be alone)\n\
\n\
@@ -104,6 +105,7 @@ int
main (int argc, char **argv)
{
int display_return = 1, do_v9 = 0;
+ int allow_options = 1;
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -113,12 +115,14 @@ main (int argc, char **argv)
/* Don't recognize --help or --version if POSIXLY_CORRECT is set. */
if (getenv ("POSIXLY_CORRECT") == NULL)
parse_long_options (argc, argv, "echo", GNU_PACKAGE, VERSION, usage);
+ else
+ allow_options = 0;
/* System V machines already have a /bin/sh with a v9 behaviour. We
use the identical behaviour for these machines so that the
existing system shell scripts won't barf. */
#if defined (V9_ECHO) && defined (V9_DEFAULT)
- do_v9 = 1;
+ do_v9 = allow_options;
#endif
--argc;
@@ -147,13 +151,13 @@ main (int argc, char **argv)
Handle them. */
while (*temp)
{
- if (*temp == 'n')
+ if (allow_options && *temp == 'n')
display_return = 0;
#if defined (V9_ECHO)
- else if (*temp == 'e')
+ else if (allow_options && *temp == 'e')
do_v9 = 1;
# if defined (V9_DEFAULT)
- else if (*temp == 'E')
+ else if (allow_options && *temp == 'E')
do_v9 = 0;
# endif /* V9_DEFAULT */
#endif /* V9_ECHO */