sh: Send getopts error messages to stderr, not stdout.
Adjust a testcase for this change.
This commit is contained in:
parent
bc7f6652dd
commit
8c4e5fc061
@ -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;
|
||||||
|
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user