Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4194304pxu; Mon, 21 Dec 2020 06:32:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzD7by2+GsyzEw9+d5DnA+j2/LEDkosTVf72VFw8yGAm9YNRsJy2JC6GJfD3UR9vFHX62Z X-Received: by 2002:a17:907:118e:: with SMTP id uz14mr14344638ejb.83.1608561151138; Mon, 21 Dec 2020 06:32:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608561151; cv=none; d=google.com; s=arc-20160816; b=BUkmU+ItEBMlCzTiydizGQIAlp0SjbU/cKhTkZvuUJ4N98H0S2ymqMvZbtSlDp6KLF 6x9ST6bHmOst+OeXq4bz3CprsmmbkPIg1UEFFk2GNcW7d6KgOYURD/qALgbOczNhi+z5 iwCdLCcZwUqwdJ+zFs9FT+qzalrLIB0H+l2Uaq4I2uWFTwob0d5LMFvjhtIU+C28Jqqt 1zapD0m2N4nVbEsBQAg2PicFlYUxF9A4j3BpXazNQrZ1YhF/qIR2D04k/1GoDW08GmX6 LvdRvckFV6BfULiviTTZUJjcqU7XGRNYxPlSrLWhh5wGjYWrrJ+RPTkT35WjCbLWS2OY uC5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=PY+0ThPVWND3Lt3Y+ClnFLJcNefmldtQqyCaw9pnlNY=; b=Sqf4WvDDf7Q5VYsXuJGHkD596KGx0rjNGAMmfK9+w7bqhqsw4MoQxWjWXZ1vjIx67+ qjPosLUopFBvBob9JJXk75LZWbMeCZEj+tPdpM+dt9DNlN+XmWdh6YqrHS2UxpFMKOg4 bHqNsgYBXWfF00M8vlg/Krw6/YZiZ3OknbZv+iGsTxY8MsJPkkoa+IMHNFXjP8YdvgFv a4DFWdzEfI2LD5QugV8O+5/w39I4iuVx1NJEOGVmXnyeT+2n0bzUCezWjZo3Hke8GjPT +zRW0xQvDfHwZWsIAhh/nYI/AkzUmZ/Glafrpu1Yi6bd9hc1r29sTLYlEdpbFbJfPgyQ VljA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Bw3IaApZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d16si10452640edp.251.2020.12.21.06.32.07; Mon, 21 Dec 2020 06:32:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=Bw3IaApZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727201AbgLUObD (ORCPT + 99 others); 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-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