All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kent Gibson <warthog618@gmail.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	linux-gpio@vger.kernel.org
Subject: Re: [PATCH libgpiod v2 2/4] tools: tests: use "$@" instead of $*
Date: Mon, 27 May 2024 21:20:50 +0800	[thread overview]
Message-ID: <20240527132050.GA133150@rigel> (raw)
In-Reply-To: <20240527125732.GA121700@rigel>

On Mon, May 27, 2024 at 08:57:32PM +0800, Kent Gibson wrote:
> On Mon, May 27, 2024 at 02:51:52PM +0200, Bartosz Golaszewski wrote:
> > On Mon, May 27, 2024 at 2:44 PM Kent Gibson <warthog618@gmail.com> wrote:
> > >
> > > On Mon, May 27, 2024 at 02:02:34PM +0200, Bartosz Golaszewski wrote:
> > > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > > >
> > > > $@ does not break up quoted arguments which is what we want in all cases
> > > > in the bash test-suite. Use it instead of $*. While at it: prevent
> > > > globbing with double quotes but allow variable expansion.
> > > >
> > > > Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > > > ---
> > > >  tools/gpio-tools-test.bash | 12 ++++++------
> > > >  1 file changed, 6 insertions(+), 6 deletions(-)
> > > >
> > > > diff --git a/tools/gpio-tools-test.bash b/tools/gpio-tools-test.bash
> > > > index abb2f5d..dde26b4 100755
> > > > --- a/tools/gpio-tools-test.bash
> > > > +++ b/tools/gpio-tools-test.bash
> > > > @@ -27,10 +27,10 @@ GPIOSIM_APP_NAME="gpio-tools-test"
> > > >  MIN_KERNEL_VERSION="5.17.4"
> > > >  MIN_SHUNIT_VERSION="2.1.8"
> > > >
> > > > -# Run the command in $* and fail the test if the command succeeds.
> > > > +# Run the command in $@ and fail the test if the command succeeds.
> > > >  assert_fail() {
> > > > -     $* || return 0
> > > > -     fail " '$*': command did not fail as expected"
> > > > +     "$@" || return 0
> > > > +     fail " '$@': command did not fail as expected"
> > > >  }
> > > >
> > >
> > > Ironically, shellcheck doesn't like the '$@' in the fail string[1], so you
> > > should use $* there.
> > >
> > > It also doesn't like looping on find results in patch 4[2], though that
> > > is not related to your change, so leave it and I'll fix it later?
> > >
> >
> > What does it want here? This looks correct to me? Should we do "$(find...)"?
> >
>
> Refer to the referenced link - it is worried about filenames containing
> whitespace.
> Not sure what the best option is here - I am only just looking into it...
>

How about using this for the cleanup:

		echo 0 > "$DEVPATH/live"
		find "$DEVPATH" -type d -name hog -exec rmdir '{}' '+'
		find "$DEVPATH" -type d -name "line*" -exec rmdir '{}' '+'
		find "$DEVPATH" -type d -name "bank*" -exec rmdir '{}' '+'
		rmdir "$DEVPATH"

It is a bit less subtle, but that works for me.

Cheers,
Kent.

  reply	other threads:[~2024-05-27 13:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-27 12:02 [PATCH libgpiod v2 0/4] tools: tests: fix a few issues in bash scripts Bartosz Golaszewski
2024-05-27 12:02 ` [PATCH libgpiod v2 1/4] tools: tests: use tabs for indentation consistently Bartosz Golaszewski
2024-05-27 12:02 ` [PATCH libgpiod v2 2/4] tools: tests: use "$@" instead of $* Bartosz Golaszewski
2024-05-27 12:44   ` Kent Gibson
2024-05-27 12:51     ` Bartosz Golaszewski
2024-05-27 12:57       ` Kent Gibson
2024-05-27 13:20         ` Kent Gibson [this message]
2024-05-27 15:45           ` Bartosz Golaszewski
2024-05-27 16:17     ` Andy Shevchenko
2024-05-27 23:39       ` Kent Gibson
2024-05-29 13:08         ` Andy Shevchenko
2024-05-29 13:18           ` Kent Gibson
2024-05-29 13:27             ` Andy Shevchenko
2024-05-29 13:44               ` Kent Gibson
2024-05-29 14:33                 ` Andy Shevchenko
2024-05-30  0:22                   ` Kent Gibson
2024-05-30 14:14                     ` Andy Shevchenko
2024-05-27 16:20     ` Andy Shevchenko
2024-05-27 23:54       ` Kent Gibson
2024-05-29 13:11         ` Andy Shevchenko
2024-05-27 12:02 ` [PATCH libgpiod v2 3/4] tools: tests: remove unneeded ';' in while loops Bartosz Golaszewski
2024-05-27 12:02 ` [PATCH libgpiod v2 4/4] tools: tests: remove dependency on grep Bartosz Golaszewski
2024-05-27 16:16   ` Andy Shevchenko

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=20240527132050.GA133150@rigel \
    --to=warthog618@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /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.