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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 235A8C677F1 for ; Sun, 15 Jan 2023 02:40:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230353AbjAOCkE (ORCPT ); Sat, 14 Jan 2023 21:40:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229971AbjAOCkC (ORCPT ); Sat, 14 Jan 2023 21:40:02 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55CA2A248; Sat, 14 Jan 2023 18:40:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CE79660BDC; Sun, 15 Jan 2023 02:40:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BC6AC433F1; Sun, 15 Jan 2023 02:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1673750400; bh=0TIlpXUyLjXgCWJoz/frRR9jRP9rDDMVSVFqtR3tMeA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=u3QZQEsTqOENmtWwRPaMnAqKojLu2ZcEpTbuaJn5T7141w0ECFE67bSBG/MhHITmQ su607huar2CJEEYnnvyDc4t+pmLIrTajd+ugnd3td9218542nDk2t7AjbaKeH5f4y+ aK4OcTvgltK3zRD0uKBns0lF68tb0+BDk+MezEjM1Q+ROIzrnv/rAquczd04gnhJTl QCkAV4ThOvNGdpDsCLVyZQtX5BBTUA11CbrGjEWrVDVLXerAQhYulwzDVTdTHgsD4S 1W3t/qnoSj674g9xGSa/tdji22kBu26q/CHuNbgqE9LyDfjYaaSpE4mSScGRot43OZ qDYiQ5XJYLhjw== Received: by mail-ot1-f42.google.com with SMTP id p17-20020a9d6951000000b00678306ceb94so14364540oto.5; Sat, 14 Jan 2023 18:39:59 -0800 (PST) X-Gm-Message-State: AFqh2ko8yOICMu+lY0Io/c6hxwwI300uYaaJFaf/+yjvtEvy4MHoWEvd c2VwaJMNOuwGsGs8kjlk07B+YraQ61myETMT5Gg= X-Google-Smtp-Source: AMrXdXtoyZNoBhCTlW2oVmTW6Au80Bu7uDXtz+FY9yhcsQaPhStbX/RPkg215wnou5HpVqBqN5lA8VUlPXTllDvcaFI= X-Received: by 2002:a05:6830:14c7:b0:684:a3ad:87e8 with SMTP id t7-20020a05683014c700b00684a3ad87e8mr1046643otq.225.1673750399222; Sat, 14 Jan 2023 18:39:59 -0800 (PST) MIME-Version: 1.0 References: <20230109204520.539080-1-ojeda@kernel.org> <20230109204520.539080-5-ojeda@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Sun, 15 Jan 2023 11:39:22 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 5/6] kbuild: rust_is_available: fix confusion when a version appears in the path To: Miguel Ojeda Cc: Miguel Ojeda , linux-kbuild@vger.kernel.org, Nathan Chancellor , Nick Desaulniers , Nicolas Schier , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: rust-for-linux@vger.kernel.org On Sat, Jan 14, 2023 at 8:13 AM Miguel Ojeda wrote: > > On Thu, Jan 12, 2023 at 6:32 AM Masahiro Yamada wrote: > > > > +set -- ${bindgen_libclang_output#**clang version} > > +bindgen_libclang_cversion=$(get_canonical_version $1) > > bindgen_libclang_min_version=$($min_tool_version llvm) > > -bindgen_libclang_cversion=$(get_canonical_version $bindgen_libclang_version) > > Nice trick :) To be honest, I am not really fond of `set`, and in this > case it means the command is not symmetric (we remove the prefix using > parameter expansion, and the suffix via positional argument > selection), but if you prefer it that way, I think it would be fine. I just tend to write efficient code. (scripts/{cc,ld,as}-version.sh do not use sed or grep at all.) Especially, I avoid unneeded process forks in the process forks. > However, why the double asterisk? One already matches any string, > including spaces, no? Sorry, it is my mistake. I meant double pound. set -- ${bindgen_libclang_output##*clang version} The double pound strips "the longest matching pattern", just in case "clang version" is contained in the file path. (but if a space is contained in the directory path, it would have failed earlier. > > Cheers, > Miguel -- Best Regards Masahiro Yamada