ash: [BUILTIN] Treat OPTIND=0 in the same way as OPTIND=1
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 26 Oct 2016 00:03:37 +0000 (02:03 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 26 Oct 2016 00:03:37 +0000 (02:03 +0200)
commita513bf3c3ce0756c991b21c0ca271e24fedcdb51
tree3e2e210badd57f1e9489ff465b79944b1c1904a0
parent88e15703acdbfb182440cf35fdb8972fc4931dd2
ash: [BUILTIN] Treat OPTIND=0 in the same way as OPTIND=1

Upstream commit:

    Date: Sat, 6 Oct 2007 18:59:31 +0800
    [BUILTIN] Treat OPTIND=0 in the same way as OPTIND=1

    Previously setting OPTIND to 0 would cause subsequent getopts calls to fail.
    This patch makes dash reset the getopts parameters the same way as OPTIND=1.

    Both behaviours are allowed by POSIX but other common shells do tolerate this
    case.

function                                             old     new   delta
getoptsreset                                          24      30      +6
getoptscmd                                           632     614     -18

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c