[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNAT0-_C3N1AO9uPV-G9U99YMeusD5HULnSmX2CfswQsuYQ@mail.gmail.com>
Date: Mon, 21 Dec 2020 23:29:10 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: David Laight <David.Laight@...lab.com>
Cc: "linux-kbuild@...r.kernel.org" <linux-kbuild@...r.kernel.org>,
Dominique Martinet <asmadeus@...ewreck.org>,
Michal Marek <michal.lkml@...kovi.net>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] kbuild: rewrite ld-version.sh in shell script
On Sun, Dec 13, 2020 at 6:47 AM David Laight <David.Laight@...lab.com> wrote:
>
> From: Masahiro Yamada
> > Sent: 12 December 2020 16:55
> >
> > This script was written in awk in spite of the file extension '.sh'.
> > Rewrite it as a shell script.
> ...
> > +#
> > +# Usage: $ ./scripts/ld-version.sh ld
> > +#
> > +# Print the linker version of `ld' in a 5 or 6-digit form
> > +# such as `23501' for GNU ld 2.35.1 etc.
> > +
> > +first_line="$($* --version | head -n 1)"
> > +
> > +if ! ( echo $first_line | grep -q "GNU ld"); then
> > + echo 0
> > + exit 1
> > +fi
> > +
> > +# Distributions may append an extra string like 2.35-15.fc33
> > +# Take the part that consists of numbers and dots.
> > +VERSION=$(echo $first_line | sed 's/.* \([^ ]*\)$/\1/' | sed 's/^\(^[0-9.]*\).*/\1/')
> > +MAJOR=$(echo $VERSION | cut -d . -f 1)
> > +MINOR=$(echo $VERSION | cut -d . -f 2)
> > +PATCHLEVEL=$(echo $VERSION | cut -d . -f 3)
> > +printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
>
>
> Hmmmm.....
> You've managed to convert an awk script into something that requires
> sh, head, grep, sed (twice), and cut (thrice).
> Plus (probably) a few sub-shells.
>
> It is quite ease to do it all in all in the shell.
>
> David
>
OK, please rewrite the code.
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists