From: David Laight <David.Laight@ACULAB.COM>
To: 'Dominique Martinet' <asmadeus@codewreck.org>,
Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Masahiro Yamada <masahiroy@kernel.org>,
Michal Marek <michal.lkml@markovi.net>,
"linux-kbuild@vger.kernel.org" <linux-kbuild@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>
Subject: RE: [PATCH 1/2] ld-version: use /usr/bin/env awk for shebank
Date: Thu, 10 Dec 2020 22:43:28 +0000 [thread overview]
Message-ID: <a9bc168cd2b84cc29e6cd4d25387a4f4@AcuMS.aculab.com> (raw)
In-Reply-To: <20201210122202.GA8323@nautica>
From: 'Dominique Martinet'
> Sent: 10 December 2020 12:22
>
> Vincenzo Frascino wrote on Thu, Dec 10, 2020:
> > On 12/9/20 10:03 PM, David Laight wrote:
> >> Why bother with awk?
>
> I wanted to keep the patch minimal, I'm not opposed to rewriting but
> that always potentially has more impact (although as you say, this
> script is simple enough)
>
> > > I think you can do it all in a shell function.
> > > Something like:
> > > read line
> > > line=${line##*)}
> > > line=${line##*version }
> > > IFS='.-'
> > > set $line
> > > echo $(($1*100000000 + $2*1000000 + $3*10000))
> > >
> > > That will work on any recent shell.
>
> Works for me.
That was a very quick rewrite of what I think the awk script did.
However I think the version is in the last space-separated word.
So you can do (untested):
read line
set line
shift $(($#-1))
OIFS="$IFS"
IFS='.-'
set $1
IFS="$OIFS"
echo $(($1*100000000 + $2*1000000 + $3*10000))
Now, if you want a version that will work with a real bourne shell
(that doesn't support $((expr)) or $(x##b} it gets more interesting.
Yes, but for now, revert first.
It might even be that the whole file isn't needed.
If it only used from a Makefile it can be gone with gmake commands.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2020-12-10 22:59 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 13:17 [PATCH 1/2] ld-version: use /usr/bin/env awk for shebank Dominique Martinet
2020-12-01 13:17 ` [PATCH 2/2] kbuild: don't hardcode depmod path Dominique Martinet
2020-12-01 13:52 ` [PATCH 1/2] ld-version: use /usr/bin/env awk for shebank Masahiro Yamada
2020-12-09 17:32 ` Vincenzo Frascino
2020-12-09 17:42 ` Dominique Martinet
2020-12-09 22:03 ` David Laight
2020-12-10 10:40 ` Vincenzo Frascino
2020-12-10 12:22 ` 'Dominique Martinet'
2020-12-10 22:43 ` David Laight [this message]
2020-12-09 18:22 ` Guenter Roeck
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=a9bc168cd2b84cc29e6cd4d25387a4f4@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=asmadeus@codewreck.org \
--cc=krzk@kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=michal.lkml@markovi.net \
--cc=vincenzo.frascino@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox