patch for echo

Arne Becker <[email protected]> Fri, 02 Apr 2004 18:37:41 +0200
Newsgroups gmane.comp.gnu.sh-utils.bugs
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------030101090101030609020903
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi.
Since it is impossible to output just "-en" with the current echo, 
here's a patch for that.

E.g "echo -- -en" gives "-- -en".
With the patch, argument parsing is stopped after encountering a '--',
the above example gives "-en".
echo -
echo ---
echo --en
still work as expected, with output
-
---
--en
respectively.

Use with
patch -p0 echo.c <patch

Maybe noone ever wants to echo -en anyway ;-)

Greets, Arne

--------------030101090101030609020903
Content-Type: text/plain;
 name="patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch"

--- a/echo.c	Fri Apr  2 17:31:11 2004
+++ b/echo.c	Fri Apr  2 18:30:20 2004
@@ -55,12 +55,12 @@
 
 #if defined (V9_ECHO)
 # if defined (V9_DEFAULT)
-#  define VALID_ECHO_OPTIONS "neE"
+#  define VALID_ECHO_OPTIONS "-neE"
 # else
-#  define VALID_ECHO_OPTIONS "ne"
+#  define VALID_ECHO_OPTIONS "-ne"
 # endif /* !V9_DEFAULT */
 #else /* !V9_ECHO */
-# define VALID_ECHO_OPTIONS "n"
+# define VALID_ECHO_OPTIONS "-n"
 #endif /* !V9_ECHO */
 
 /* The name this program was run with. */
@@ -164,6 +164,16 @@
 #if defined (V9_ECHO)
 	  else if (allow_options && *temp == 'e')
 	    do_v9 = 1;
+	  /* End option parsing after encountering a --, do not output the --
+	   * or, if we have a --, and anything after that, do output that
+	   * */
+	  else if (allow_options && *temp == '-'){
+		  if (! (*(temp + 1))){
+				argc--;
+				argv++;
+		  }
+		goto just_echo;
+      }
 # if defined (V9_DEFAULT)
 	  else if (allow_options && *temp == 'E')
 	    do_v9 = 0;

--------------030101090101030609020903
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Bug-sh-utils mailing list
[email protected]
http://mail.gnu.org/mailman/listinfo/bug-sh-utils

--------------030101090101030609020903--