mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
common/xfs: Initialise OPTIND for getopts calls
According to the bash man page: OPTIND is initialized to 1 each time the shell or a shell script is invoked. This doesn't appear to be true - in tests scripts with no other getopts calls, I'm seeing the getopts loop in _xfs_check to fail to parse input parameters correctly. Tracing shows the parameters are being passed to _xfs_check correctly, but on occassion getopts simply doesn't see them. Hence when running tests with both external log and real time devices, tests are failing at random because xfs_check is mis-parsing the parameters passed to it and not configuring the external log correctly: _check_xfs_filesystem: filesystem on /dev/sdg is inconsistent (c) *** xfs_check output *** aborting - no external log specified for FS with an external log *** end xfs_check output Fix this by ensuring OPTIND is correctly initialised before using getopts. Do it for all places that call getopts that don't already set OPTIND=1 before starting their parsing loop. Signed-Off-By: Dave Chinner <dchinner@redhat.com> Reviewed-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
@@ -87,6 +87,7 @@ _usage()
|
||||
|
||||
_process_args()
|
||||
{
|
||||
OPTIND=1
|
||||
while getopts "f:l:n:?" c $@
|
||||
do
|
||||
case $c
|
||||
|
||||
@@ -98,6 +98,7 @@ _usage()
|
||||
|
||||
_process_args()
|
||||
{
|
||||
OPTIND=1
|
||||
while getopts "l:n:N:?" c $@
|
||||
do
|
||||
case $c
|
||||
|
||||
@@ -94,6 +94,7 @@ _usage()
|
||||
|
||||
_process_args()
|
||||
{
|
||||
OPTIND=1
|
||||
while getopts "l:n:N:?" c $@
|
||||
do
|
||||
case $c
|
||||
|
||||
Reference in New Issue
Block a user