]> git.ipfire.org Git - thirdparty/linux-firmware.git/commitdiff
copy-firmware: make script smarter about bad parameters
authorTimur Tabi <ttabi@nvidia.com>
Mon, 17 Mar 2025 18:32:15 +0000 (13:32 -0500)
committerTimur Tabi <ttabi@nvidia.com>
Mon, 17 Mar 2025 22:45:37 +0000 (17:45 -0500)
Two improvements to copy-firmware.sh that make it more friendly
when passed unknown or not exactly correct command-line parameters.

1) Don't fail with a weird error if there's a space between -j and
   the number.

2) Ignore any command-line unsupported parameters that start with
   a dash.  This is necessary because otherwise the script will
   assume the option is actually a destination directory, and then
   the "test" command will get confused.  Drawback is that we don't
   support any more destination directories that start with a dash,
   but no one does that.

Signed-off-by: Timur Tabi <ttabi@nvidia.com>
copy-firmware.sh

index 9a2b71568e0f682dc7ac792a8bf1a6ffbda5f25b..cd5a689392334ff2dd95907b98bbf2e90c35c370 100755 (executable)
@@ -44,6 +44,7 @@ while test $# -gt 0; do
 
         -j*)
             num_jobs=$(echo "$1" | sed 's/-j//')
+            num_jobs=${num_jobs:-1}
             if [ "$num_jobs" -gt 1 ] && ! has_gnu_parallel; then
                     err "the GNU parallel command is required to use -j"
             fi
@@ -76,6 +77,13 @@ while test $# -gt 0; do
             exit 1
             ;;
 
+        -*)
+            # Ignore anything else that begins with - because that confuses
+            # the "test" command below
+            warn "ignoring option $1"
+            shift
+            ;;
+
         *)
             if test -n "$destdir"; then
                 err "unknown command-line options: $*"