All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: Timur Tabi <ttabi@nvidia.com>,
	jwboyer@kernel.org, maxim.cournoyer@gmail.com,
	linux-firmware@kernel.org
Subject: Re: [PATCH 1/2] copy-firmware: make script smarter about parameters
Date: Mon, 17 Mar 2025 15:27:12 -0500	[thread overview]
Message-ID: <3c09c8a1-21c3-49f6-9e41-e409fd38883a@kernel.org> (raw)
In-Reply-To: <20250317191606.64181-1-ttabi@nvidia.com>

On 3/17/2025 14:16, Timur Tabi wrote:
> Several improvements to copy-firmware.sh that make it more friendly
> when passed unknown or not exactly correct command-line parameters.
> 
> 1) Add a usage() function to show the command-line options.
> 2) Print that usage on all errors.
> 3) Don't fail with a weird error if there's a space between -j and
>     the number.
> 4) Add support for the -h or --help options.
> 5) 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 | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)

/Conceptually/ I'm aligned on everything in this patch.

A few things.

1) One patch per change please.
2) It appears that the second patch in this this series fails CI.  You 
should install pre-commit or run `make check` to check before submitting 
in the future.

Here are the details of the failure.

https://gitlab.com/kernel-firmware/linux-firmware/-/merge_requests/486

BTW - In general it would be better to submit a MR so that you could 
just force push a fix.

> 
> diff --git a/copy-firmware.sh b/copy-firmware.sh
> index dd4b9b6f..cd5a6893 100755
> --- a/copy-firmware.sh
> +++ b/copy-firmware.sh
> @@ -11,8 +11,13 @@ compext=
>   destdir=
>   num_jobs=1
>   
> +usage() {
> +    echo "Usage: $0 [-v] [-jN] [--xz|--zstd] <destination directory>"
> +}
> +
>   err() {
>       printf "ERROR: %s\n" "$*"
> +    usage
>       exit 1
>   }
>   
> @@ -39,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
> @@ -66,6 +72,18 @@ while test $# -gt 0; do
>               shift
>               ;;
>   
> +        -h|--help)
> +            usage
> +            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: $*"


  parent reply	other threads:[~2025-03-17 20:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17 19:16 [PATCH 1/2] copy-firmware: make script smarter about parameters Timur Tabi
2025-03-17 19:16 ` [PATCH 2/2] copy-firmware: fail gracefully if moreutils parallel is installed Timur Tabi
2025-03-18  6:20   ` Maxim Cournoyer
2025-03-18  7:06     ` Timur Tabi
2025-03-18  6:42   ` Maxim Cournoyer
2025-03-18  7:08     ` Timur Tabi
2025-03-18 14:58       ` Maxim Cournoyer
2025-03-18 15:14         ` Timur Tabi
2025-03-17 20:27 ` Mario Limonciello [this message]
2025-03-17 21:14   ` [PATCH 1/2] copy-firmware: make script smarter about parameters Timur Tabi
2025-03-17 21:16     ` Mario Limonciello
2025-03-17 21:45   ` Timur Tabi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3c09c8a1-21c3-49f6-9e41-e409fd38883a@kernel.org \
    --to=superm1@kernel.org \
    --cc=jwboyer@kernel.org \
    --cc=linux-firmware@kernel.org \
    --cc=maxim.cournoyer@gmail.com \
    --cc=ttabi@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.