[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
patch for echo
From: |
Arne Becker |
Subject: |
patch for echo |
Date: |
Fri, 02 Apr 2004 18:37:41 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040116 |
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
--- 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;
- patch for echo,
Arne Becker <=