Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4826310pxu; Thu, 10 Dec 2020 06:29:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIFRyNFL88iixq7qbtRwn7w9eriBd6mh7qsJVA96p0Ynk2mO5xuAHw9xWJ6gCQUQHX6sMa X-Received: by 2002:a17:906:4c4c:: with SMTP id d12mr6599183ejw.307.1607610545615; Thu, 10 Dec 2020 06:29:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607610545; cv=none; d=google.com; s=arc-20160816; b=a7JU4GojK+2Y+9yVgfFlHHoDBxCZDTe95aIF9b2EtecqK0OrBhlvfpesJxJA4pYbd4 D69/kUz5nxnkMqZS+HN6E3mCuUQ66VJRJhDBekcvVHt9NOy2WiUAovAsTcJ/iZaXy4SS PCbbywf6aEKCtwAkCvNB/vhtcOpGKuP+G5JN+WGVaGS7io/YnE22Vwjowe662szDj5ti U9/Bd18RFnT2+pNkpROigABKOY7lDSMdS6mub+RlEAjFIB0XBPDbnm7oAm/E7mOhfoNU AGdg8PzTmM7OnJWHSk4KZZ9xSZrEoHqxdGuPUI5gh9nietef3KBupSgrQteNhNvJSSko JJgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=TNDh1Hbulc3hLegWX9xRbd9r7Q8bRrvwm0je/sP+aec=; b=XR82U2nHDGsW7QVsMhHCoNU6VuB7xV5xIx5rrQL+KdhNRFtEiwfZMYuTHZpQMabkx7 PmDtsloS97TudMZAZsECy2G4FyEO6quOUfS4hty4/BBDdT4IgA+WbBuAIRHrMoMMNGxT Eq4y3LGT/8R4JAR7pfnnNfN183+BSAajOB5Y5IBho0CmiURSvzVhSUhZyhU1qrHDSN3U FI6qRnyo3fDng/rCuzjOu1Srgw6vkhnRnbvzqWhmtct++wqxbep4sNq6HiSZKjXegGk5 oUfk48Eut9KqNHTAnPPWqDDFYLl9rMSCoMUTrx2PqzJyaH6SAyPATd6jhaLTWEg/KaiY WAhA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q8si2899419edg.582.2020.12.10.06.28.43; Thu, 10 Dec 2020 06:29:05 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730573AbgLJKh2 (ORCPT + 99 others); Thu, 10 Dec 2020 05:37:28 -0500 Received: from foss.arm.com ([217.140.110.172]:34112 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726768AbgLJKh2 (ORCPT ); Thu, 10 Dec 2020 05:37:28 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 29C8731B; Thu, 10 Dec 2020 02:36:42 -0800 (PST) Received: from [10.37.8.43] (unknown [10.37.8.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7B78F3F718; Thu, 10 Dec 2020 02:36:40 -0800 (PST) Subject: Re: [PATCH 1/2] ld-version: use /usr/bin/env awk for shebank To: David Laight , 'Dominique Martinet' Cc: Masahiro Yamada , Michal Marek , "linux-kbuild@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Krzysztof Kozlowski References: <1606828650-29841-1-git-send-email-asmadeus@codewreck.org> <69c82aee-59ec-f8d8-9546-b38f85bf08c0@arm.com> <20201209174252.GA27721@nautica> <5ca5c3bb23614af0a35f01f1e3a84ead@AcuMS.aculab.com> From: Vincenzo Frascino Message-ID: Date: Thu, 10 Dec 2020 10:40:01 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <5ca5c3bb23614af0a35f01f1e3a84ead@AcuMS.aculab.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dominique and Dave, On 12/9/20 10:03 PM, David Laight wrote: > From: Dominique Martinet >> Sent: 09 December 2020 17:43 >> >> I've suggested either just reverting this (I'll keep my local >> workaround) or going through /bin/sh which is always safe like the >> following patch -- leaving this to maintainers. >> >> Thanks! >> ----- >> From d53ef3b4c55aa2ea5f9ae887b3e1ace368f30f66 Mon Sep 17 00:00:00 2001 >> From: Dominique Martinet >> Date: Wed, 15 Jul 2020 16:00:13 +0200 >> Subject: [PATCH] ld-version: use /bin/sh then awk for shebank >> >> /usr/bin/awk is not garanteed to exist (and doesn't on e.g. nixos), >> using /bin/sh and invoking awk to have it look in PATH is more robust. >> >> Signed-off-by: Dominique Martinet >> >> diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh >> index f2be0ff9a738..02dbad7b5613 100755 >> --- a/scripts/ld-version.sh >> +++ b/scripts/ld-version.sh >> @@ -1,11 +1,11 @@ >> -#!/usr/bin/awk -f >> +#!/bin/sh >> # SPDX-License-Identifier: GPL-2.0 >> # extract linker version number from stdin and turn into single number >> - { >> +awk '{ >> gsub(".*\\)", ""); >> gsub(".*version ", ""); >> gsub("-.*", ""); >> split($1,a, "."); >> print a[1]*100000000 + a[2]*1000000 + a[3]*10000; >> exit >> - } >> +}' > > Why bother with awk? > 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. > I would suggest to revert the patch for now since we are close to the merge window and then maybe in -rc1 start discussing a better solution. What do you think? > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) > -- Regards, Vincenzo