]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
src/bin/grepc: Add defensive check
authorAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 22:40:38 +0000 (23:40 +0100)
committerAlejandro Colomar <alx@kernel.org>
Fri, 31 Oct 2025 11:22:57 +0000 (12:22 +0100)
In theory, getopts(1) will make sure that no other values arrive here.
However, it's easy to add a check, and that will be safer than silencing
shellcheck(1).

Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/bin/grepc

index 102396273cef9632ea44c85b238633e8e4253ac1..4f92c8638f8eff9cca8def9ee17ab3a01c4dd363 100755 (executable)
@@ -52,7 +52,6 @@ grepc_err()
 
 
 while getopts "A:B:C:chilm:nrt:x:" opt; do
-       # shellcheck disable=SC2249  # getopts(1) uses '?' for an error.
        case "$opt" in
        A)      A="-A$OPTARG";  ;;
        B)      B="-B$OPTARG";  ;;
@@ -133,7 +132,7 @@ while getopts "A:B:C:chilm:nrt:x:" opt; do
                        ;;
                esac;
                ;;
-       \?)
+       \? | *)
                exit 1;
                ;;
        esac;