Silence SC2317

Otherwise https://www.shellcheck.net/ would complain:
  Line 2479:
  shift
  ^---^ SC2317 (info): Command appears to be unreachable. Check usage
    (or ignore if invoked indirectly).

See: https://www.shellcheck.net/wiki/SC2317

Fedora Rawhide now has ShellCheck-0.9.0, which flags these new problems,
while so far it only had ShellCheck-0.8.0.

ShellCheck is correct that this is unreachable code.  However, given the
lack of built-in command line parsing facilities in POSIX shell, this
code pattern has so far turned out to be quite handy.  It's flexible
enough to be able to handle different combinations of commands and
options, and is easy to read.  Trying to 'fix' the code will likely
cause more problems than it will solve.

Moreover, the POSIX shell implementation has been replaced by the Go
implementation quite a long time ago.  It's no longer maintained and has
been kept only for historical reasons.  Therefore, it's not worth
spending any significant amount of time on it.

https://github.com/containers/toolbox/pull/1211
This commit is contained in:
Debarshi Ray 2023-01-12 14:15:05 +01:00
parent c2f0ebc5bc
commit 07bc3bb42b

View file

@ -2476,6 +2476,7 @@ case $op in
* ) * )
exit_if_unrecognized_option "$1" exit_if_unrecognized_option "$1"
esac esac
# shellcheck disable=SC2317
shift shift
done done
help "$1" help "$1"
@ -2556,6 +2557,7 @@ case $op in
* ) * )
exit_if_unrecognized_option "$1" exit_if_unrecognized_option "$1"
esac esac
# shellcheck disable=SC2317
shift shift
done done
exit_if_extra_operand "$1" exit_if_extra_operand "$1"