Re: [PATCH 1/1] gpio: add sloppy logic analyzer using polling

From
Andy Shevchenko <hidden>
Date
2021-09-06 10:16:10
Also in
linux-renesas-soc, lkml
Reply to
Wolfram Sang, 2021-09-06
On Mon, Sep 6, 2021 at 12:04 PM Wolfram Sang
[off-list ref] wrote:

...
quoted
quoted
+#!/bin/sh -eu
Next step is to add 'f' to the mix here :-)
-f broke zip file generation in a way I didn't know how to resolve
differently. Sadly, I can't recall the details right now.
Yes, it means you are not able to use * (a.k.a. glob() function) in
the shell which increases a lot security and other (misuse) concerns.
Instead you have to use `find` or similar tools to collect the list of
the files of your interest.

...
quoted
quoted
+while true; do
+       case "$1" in
+       -c|--cpu) initcpu="$2"; shift 2;;
+       -d|--duration-us) duration="$2"; shift 2;;
+       -h|--help) print_help; exit 0;;
+       -i|--instance) lasysfsdir="$sysfsdir/$2"; shift 2;;
+       -k|--kernel-debug-dir) debugdir="$2"; shift 2;;
+       -n|--num_samples) numsamples="$2"; shift 2;;
+       -o|--output-dir) outputdir="$2"; shift 2;;
+       -s|--sample_freq) samplefreq="$2"; shift 2;;
+       -t|--trigger) triggerdat="$2"; shift 2;;
+       --)     shift; break;;
+       *)      fail "error parsing commandline: $*";;
+       esac
I would prefer to have a clear shift here instead of doing shift 2
everywhere above (less error prone).
If we ever support binary arguments (toggles), then a generic 'shift 2'
won't work?
To me it's less error prone to have something like this:

while [ $# -gt 1 ]; do # notice the condition, btw
  case "$1" in
  opt_with_parameter) ...; shift;;
  toggler_opt) ...;;
  esac
  shift
done
quoted
quoted
+done
Either way it's minor.

-- 
With Best Regards,
Andy Shevchenko
Thread (6 messages) 6 messages, 2 authors, last reply 2021-09-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help