Fix /bin/sh's broken handling of the builtin getopts(1). The options

``-ffoo'' and ``-f foo'' have been treated differently.

This has been in violation of Posix.2 (that deprecates -ffoo, but
doesn't disallow it).
This commit is contained in:
Joerg Wunsch 1995-08-06 19:35:33 +00:00
parent 78f1a844fb
commit 78e1fb6090
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9974

View File

@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: options.c,v 1.2 1994/09/24 02:58:04 davidg Exp $
* $Id: options.c,v 1.3 1995/05/30 00:07:21 rgrimes Exp $
*/
#ifndef lint
@ -374,12 +374,11 @@ getoptscmd(argc, argv) char **argv; {
q++;
}
if (*++q == ':') {
if (*p == '\0' && (p = *shellparam.optnext) == NULL) {
if (*p == '\0' && (p = *shellparam.optnext++) == NULL) {
out1fmt("No arg for -%c option\n", c);
c = '?';
goto out;
}
shellparam.optnext++;
setvar("OPTARG", p, 0);
p = NULL;
}