test-lib: parse options in a for loop to keep $@ intact
commita9b2db379b3be3dcb7540e04f10a1d67c3bc974f
authorSZEDER Gábor <szeder.dev@gmail.com>
Sat, 5 Jan 2019 01:08:54 +0000 (5 02:08 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 7 Jan 2019 17:24:05 +0000 (7 09:24 -0800)
treed86808e7275f19a8d1ff95ab2231fbe92cd0061a
parent0a97e86e9a28746604f38eacb11119aadbadb9c8
test-lib: parse options in a for loop to keep $@ intact

'test-lib.sh' looks for the presence of certain options like '--tee'
and '--verbose-log', so it can execute the test script again to save
its standard output and error, and to do so it needs the original
command line options the test was invoked with.

The next patch is about to move the option parsing loop earlier in
'test-lib.sh', but it is implemented using 'shift' in a while loop,
effecively destroying "$@" by the end of the option parsing.  Not
good.

As a preparatory step, turn that option parsing loop into a 'for opt
in "$@"' loop to preserve "$@" intact while iterating over the
options, and taking extra care to handle the '-r' option's required
argument (or the lack thereof).

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib.sh