[edk2-devel] [PATCH 1/1] edksetup.sh: rework python executable scanning

Leif Lindholm leif.lindholm at linaro.org
Wed Jul 17 14:04:51 UTC 2019


On Tue, Jul 16, 2019 at 02:10:43PM -0600, Rebecca Cran wrote:
> On 2019-07-16 13:07, Leif Lindholm wrote:
> > +        EXECUTABLE=`basename $file`
> > +        VERSION=`echo $EXECUTABLE | sed 's/[^0-9.]//g'`
> > +
> > +        MAJOR=`echo $VERSION | sed 's/\([0-9]*\)\.*.*/\1/'`
> > +        MINOR=`echo $VERSION | sed 's/[0-9]*\.*\([0-9]*\).*/\1/'`
> > +        PATCH=`echo $VERSION | sed 's/[0-9]*\.*[0-9]*\.*\([0-9]*\)/\1/'`
> 
> Here and in other places, we should probably use $(...) instead of `...` .
> 
> From http://mywiki.wooledge.org/BashFAQ/082 :
> 
> " `...` is the legacy syntax required by only the very oldest of
> non-POSIX-compatible bourne-shells. There are several reasons to always
> prefer the $(...) syntax..."
> 
> And https://wiki.bash-hackers.org/scripting/obsolete

I also liked http://mywiki.wooledge.org/BashFAQ/082, linked from that.

> "Both the |`COMMANDS`| and |$(COMMANDS)| syntaxes are specified by
> POSIX, but the latter is _greatly_ preferred, though the former is
> unfortunately still very prevalent in scripts."

You're absolutely right.

I have in the past written scripts both for ancient UNIXen and early
busybox, so have a habit to go lowest common denominator. But this is
a _bash_ script, so there's no good reason.

If we keep the function, I'll rewrite it as suggested - thanks!

/
    Leif

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43885): https://edk2.groups.io/g/devel/message/43885
Mute This Topic: https://groups.io/mt/32495132/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-




More information about the edk2-devel-archive mailing list