]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - builtins/echo.def
Imported from ../bash-3.1.tar.gz.
[thirdparty/bash.git] / builtins / echo.def
index a91c8e4cb6e799ec91783079d9f9e99c47eb0c0d..6792659a7d214b34e562cbaa3021dc8a41a06fa1 100644 (file)
@@ -72,12 +72,14 @@ $END
    existing system shells won't barf.  Regrettably, the SUS v2 has
    standardized the Sys V echo behavior.  This variable is external
    so that we can have a `shopt' variable to control it at runtime. */
-#if defined (DEFAULT_ECHO_TO_XPG)
+#if defined (DEFAULT_ECHO_TO_XPG) || defined (STRICT_POSIX)
 int xpg_echo = 1;
 #else
 int xpg_echo = 0;
 #endif /* DEFAULT_ECHO_TO_XPG */
 
+extern int posixly_correct;
+
 /* Print the words in LIST to standard output.  If the first word is
    `-n', then don't print a trailing newline.  We also support the
    echo syntax from Version 9 Unix systems. */
@@ -91,6 +93,9 @@ echo_builtin (list)
   do_v9 = xpg_echo;
   display_return = 1;
 
+  if (posixly_correct && xpg_echo)
+    goto just_echo;
+
   for (; list && (temp = list->word->word) && *temp == '-'; list = list->next)
     {
       /* If it appears that we are handling options, then make sure that
@@ -170,6 +175,7 @@ just_echo:
   fflush (stdout);
   if (ferror (stdout))
     {
+      sh_wrerror ();
       clearerr (stdout);
       return (EXECUTION_FAILURE);
     }