svn commit: r265773 - in head/bin/sh: . tests/builtins

Jilles Tjoelker jilles at FreeBSD.org
Fri May 9 13:32:37 UTC 2014


Author: jilles
Date: Fri May  9 13:32:36 2014
New Revision: 265773
URL: http://svnweb.freebsd.org/changeset/base/265773

Log:
  sh: Send getopts error messages to stderr, not stdout.
  
  Adjust a testcase for this change.

Modified:
  head/bin/sh/options.c
  head/bin/sh/tests/builtins/getopts1.0

Modified: head/bin/sh/options.c
==============================================================================
--- head/bin/sh/options.c	Fri May  9 13:27:30 2014	(r265772)
+++ head/bin/sh/options.c	Fri May  9 13:32:36 2014	(r265773)
@@ -474,7 +474,7 @@ atend:
 				err |= setvarsafe("OPTARG", s, 0);
 			}
 			else {
-				out1fmt("Illegal option -%c\n", c);
+				out2fmt_flush("Illegal option -%c\n", c);
 				INTOFF;
 				(void) unsetvar("OPTARG");
 				INTON;
@@ -495,7 +495,7 @@ atend:
 				c = ':';
 			}
 			else {
-				out1fmt("No arg for -%c option\n", c);
+				out2fmt_flush("No arg for -%c option\n", c);
 				INTOFF;
 				(void) unsetvar("OPTARG");
 				INTON;

Modified: head/bin/sh/tests/builtins/getopts1.0
==============================================================================
--- head/bin/sh/tests/builtins/getopts1.0	Fri May  9 13:27:30 2014	(r265772)
+++ head/bin/sh/tests/builtins/getopts1.0	Fri May  9 13:32:36 2014	(r265773)
@@ -15,7 +15,7 @@ printf -- '-2-\n'
 set -- -ab
 getopts "ab:" OPTION
 echo ${OPTION}
-getopts "ab:" OPTION
+getopts "ab:" OPTION 3>&2 2>&1 >&3 3>&-
 echo ${OPTION}
 
 # The 'shift' is aimed at causing an error.


More information about the svn-src-all mailing list