sh: Send getopts error messages to stderr, not stdout.

Adjust a testcase for this change.
This commit is contained in:
Jilles Tjoelker 2014-05-09 13:32:36 +00:00
parent bc7f6652dd
commit 8c4e5fc061
2 changed files with 3 additions and 3 deletions

View File

@ -474,7 +474,7 @@ getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
err |= setvarsafe("OPTARG", s, 0); err |= setvarsafe("OPTARG", s, 0);
} }
else { else {
out1fmt("Illegal option -%c\n", c); out2fmt_flush("Illegal option -%c\n", c);
INTOFF; INTOFF;
(void) unsetvar("OPTARG"); (void) unsetvar("OPTARG");
INTON; INTON;
@ -495,7 +495,7 @@ getopts(char *optstr, char *optvar, char **optfirst, char ***optnext,
c = ':'; c = ':';
} }
else { else {
out1fmt("No arg for -%c option\n", c); out2fmt_flush("No arg for -%c option\n", c);
INTOFF; INTOFF;
(void) unsetvar("OPTARG"); (void) unsetvar("OPTARG");
INTON; INTON;

View File

@ -15,7 +15,7 @@ printf -- '-2-\n'
set -- -ab set -- -ab
getopts "ab:" OPTION getopts "ab:" OPTION
echo ${OPTION} echo ${OPTION}
getopts "ab:" OPTION getopts "ab:" OPTION 3>&2 2>&1 >&3 3>&-
echo ${OPTION} echo ${OPTION}
# The 'shift' is aimed at causing an error. # The 'shift' is aimed at causing an error.