From 07bc3bb42b7cf7d48dffae3c15a3babd22f3b7c7 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Thu, 12 Jan 2023 14:15:05 +0100 Subject: [PATCH] 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 --- toolbox | 2 ++ 1 file changed, 2 insertions(+) diff --git a/toolbox b/toolbox index 4952dff..c6d86e2 100755 --- a/toolbox +++ b/toolbox @@ -2476,6 +2476,7 @@ case $op in * ) exit_if_unrecognized_option "$1" esac + # shellcheck disable=SC2317 shift done help "$1" @@ -2556,6 +2557,7 @@ case $op in * ) exit_if_unrecognized_option "$1" esac + # shellcheck disable=SC2317 shift done exit_if_extra_operand "$1"