sh(1): Reset getopt(3) before executing built-in commands.
authorStathis Kamperis <beket@dragonflybsd.org>
Wed, 17 Jun 2009 13:21:16 +0000 (16:21 +0300)
committerStathis Kamperis <beket@dragonflybsd.org>
Wed, 17 Jun 2009 13:58:28 +0000 (16:58 +0300)
commitedc2dda3dc3fccec8603cc28bc8650188872e8d4
tree0f0393f9ed1dd97d6c4ff1402815a0c0f6957203
parent7fa32f3028faf66988e31406f65bc257b1e1db35
sh(1): Reset getopt(3) before executing built-in commands.

Before patch:
$ printf "test\n"
test
$ jobs -l
$ printf "test\n"
usage: printf format [arg ...]
$

After patch:
$ printf "test\n"
test
$ jobs -l
$ printf "test\n"
test
$

The bug isn't tight to jobs(1) or printf(1). Every use of getopt(3) would
advance `optind' and make the next built-in command think that it wasn't
supplied with enough arguments. NetBSD is doing as we do. FreeBSD doesn't
have printf(1) as built-in so it is not affected. The patch has survived
a build{world, kernel}.
bin/sh/eval.c