From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 307EFC433E0 for ; Mon, 21 Dec 2020 14:31:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 06DB922B43 for ; Mon, 21 Dec 2020 14:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727232AbgLUObD (ORCPT ); Mon, 21 Dec 2020 09:31:03 -0500 Received: from conssluserg-02.nifty.com ([210.131.2.81]:28732 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727148AbgLUObC (ORCPT ); Mon, 21 Dec 2020 09:31:02 -0500 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 0BLETlte009471; Mon, 21 Dec 2020 23:29:47 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 0BLETlte009471 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1608560987; bh=PY+0ThPVWND3Lt3Y+ClnFLJcNefmldtQqyCaw9pnlNY=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Bw3IaApZWwPkn22WMTgwWffkvKmG4J+ON3tiUcP/znPabxxBsef+qgZ83cTnKbNd5 m+9m3XxggedPMEBaUkQqIbCTUrvYyZpDIPEDwpjbo8608V71MhqlZDlZuVXkvNqooL 5BEdFagN3Pm2oSy0rq5AhfJv+4YfnXKWWIyaZ7PgJy1nRr7n1xWWNH3jy07Swv4WcZ OFTuvd0T1+ys6Q6Zzo5UCnhA2qUInjTnVkoGYjX50KIVvDz7PCwHmMYua7EIVJhO3X r5hp+FrzYzf0OJq8lKjAt3xZssv21iWdsQJDTf98DoLnZemJoxFTWRDbqLtodIGiFT PYtN/nZmmVgSg== X-Nifty-SrcIP: [209.85.215.170] Received: by mail-pg1-f170.google.com with SMTP id z21so6454580pgj.4; Mon, 21 Dec 2020 06:29:47 -0800 (PST) X-Gm-Message-State: AOAM532M7lBHV4iaBWKRykXaTkyZFu9WMrAjA0Zx1tFOYcrsEuCxGpoP FKzwLqtZutouQrA/9gan+LFswwWRwSuHls1Ehks= X-Google-Smtp-Source: ABdhPJx1i2sUSv2jDc69OziBsRnfR7tJle94dwX/H2E9VzZIt1Ci5INaQwjjjE7NMi1cp7Bn8Afrnp6quqw2QDO0c4M= X-Received: by 2002:aa7:9501:0:b029:155:3b11:d5c4 with SMTP id b1-20020aa795010000b02901553b11d5c4mr15472118pfp.76.1608560986910; Mon, 21 Dec 2020 06:29:46 -0800 (PST) MIME-Version: 1.0 References: <20201212165431.150750-1-masahiroy@kernel.org> <20201212165431.150750-3-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Mon, 21 Dec 2020 23:29:10 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] kbuild: rewrite ld-version.sh in shell script To: David Laight Cc: "linux-kbuild@vger.kernel.org" , Dominique Martinet , Michal Marek , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Dec 13, 2020 at 6:47 AM David Laight 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