Index: bin/sh/histedit.c =================================================================== --- bin/sh/histedit.c +++ bin/sh/histedit.c @@ -278,7 +278,10 @@ if (argc == 1) error("missing history argument"); - while (not_fcnumber(*argptr) && (ch = nextopt("e:lnrs")) != '\0') + nextopt_optptr = NULL; + while (not_fcnumber(nextopt_optptr ? nextopt_optptr : *argptr)) { + if ((ch = nextopt("e:lnrs")) == '\0') + break; switch ((char)ch) { case 'e': editor = shoptarg; @@ -296,6 +299,7 @@ sflg = 1; break; } + } savehandler = handler; /* Index: bin/sh/options.c =================================================================== --- bin/sh/options.c +++ bin/sh/options.c @@ -589,6 +589,9 @@ shoptarg = p; p = NULL; } - nextopt_optptr = p; + if (p != NULL && *p != '\0') + nextopt_optptr = p; + else + nextopt_optptr = NULL; return c; }