Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5147227ybg; Mon, 21 Oct 2019 21:59:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqykplMeoO7W2pocA56EMLwJmbq1B0fpR87SRd4H9CwVcXSskP2lO/01RG5IB4gwlvytXAXL X-Received: by 2002:a05:6402:1006:: with SMTP id c6mr1784914edu.2.1571720365841; Mon, 21 Oct 2019 21:59:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571720365; cv=none; d=google.com; s=arc-20160816; b=GCKbYx+7A0zfgKSwi73zQihZ4FWeFZNKov+y/p0944/wrbzPaMAyH8xpCJkJUKSRpn oIp7PLPiM+KI7VOm5E+nZkjDo5FuyUP/9u+Fzj7fFAN64sSBYy4q+3tHnv98e+mNGaZ0 MEQQ54mFfXGypYBw5gwYpfoqF11t7yzO9tHrJ+cUgAZwloO1jJhkJIQIfVRhL1sjVQdr f6Tpbd9OVAPIJQaD6zuQ9mUwpRDUSF2DF4F2LkjzeAK5VzRF06ZZBbwVvtMSv+tJr/eE K2i5ctqjoVh3mVzMGdK9ViJxzgYWi6pre4DyRZF/HiHbm9RlPQTNS3Zk9nCq1cNyrRhh VmjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=Y7m4kw56amPHSqMoZrVwVOiMi5wEMDjWOEjfzQz1ycM=; b=KIQ1R9St69B7XWwNBjc6RG6dZMtekGQCWX06ImlbJgTfMpdFEqE5BtmCDq7auB747+ CZKxNmfbH0C95o8Olh8AYq3fChmbGeCsxzpbI6HhaBOXOiZtWwcMfMh8xAw6ltK7gJLt VEuCBfBIpd6pi6O27k2x1+maHT5YHjLGP+TW4r/tDVFTfu+eGASdXTwhEd8JqapReyBV dODAbZD9NvM5ZWt43oHKbarLyUwOPUnZP97uH0dQuAxLj0ApowSZAb96gMcfcUIDPEg7 LOnSZ7R+05IT0bgVaTUj369XPRJAX2Ld04BLCwEpv32m9rb/I2mhG3GZlzoLyLcY1/Mo nZ0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ZVOfQ6au; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si10874796eds.179.2019.10.21.21.59.01; Mon, 21 Oct 2019 21:59:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ZVOfQ6au; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387442AbfJVEii (ORCPT + 99 others); Tue, 22 Oct 2019 00:38:38 -0400 Received: from conssluserg-06.nifty.com ([210.131.2.91]:22866 "EHLO conssluserg-06.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726024AbfJVEih (ORCPT ); Tue, 22 Oct 2019 00:38:37 -0400 Received: from mail-vs1-f54.google.com (mail-vs1-f54.google.com [209.85.217.54]) (authenticated) by conssluserg-06.nifty.com with ESMTP id x9M4cOAq031118 for ; Tue, 22 Oct 2019 13:38:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com x9M4cOAq031118 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1571719105; bh=Y7m4kw56amPHSqMoZrVwVOiMi5wEMDjWOEjfzQz1ycM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZVOfQ6aubywwI+UqbDwuRDPWsL82iI5ltIea8ODNs+f5vSc2ZYyejT+tTYlLJMmM7 af9GWHHClDkE8nY+ij0Sn5uSAlN0YTbndUPrbgPmcDjB/98Jweo5xr530ha/6vhL7h vbvnpRCJpXpXdO5QpwgozR8s/3C4Fz6eaP8yNDyQuZFgTilW0Es/1fk+gjUicUtbs0 0IH1PGymxW9EPT5Z+/IiWnTGcXRu5fkTaEpG7bT1toPXtJ00zVmG56owMxGXaNawNP 8t74xKLtKRICggS2ZIcKK89x16JHIcyD104U7QinyvJcvLMxjMFaRJjCmKO4x+0kL0 g6jK2m6ZT2/tw== X-Nifty-SrcIP: [209.85.217.54] Received: by mail-vs1-f54.google.com with SMTP id k15so1479644vsp.2 for ; Mon, 21 Oct 2019 21:38:24 -0700 (PDT) X-Gm-Message-State: APjAAAVV85t0PTTo0hKRr3EzooZVhvjIZszW2Qmg586T+b2qWIkl1l96 sTUlKhB0+hdi64fHToRl9M3iUZGQ79xLyJIk6eQ= X-Received: by 2002:a67:e354:: with SMTP id s20mr740200vsm.54.1571719103415; Mon, 21 Oct 2019 21:38:23 -0700 (PDT) MIME-Version: 1.0 References: <20191021145137.31672-1-jeyu@kernel.org> <20191021160419.28270-1-jeyu@kernel.org> In-Reply-To: <20191021160419.28270-1-jeyu@kernel.org> From: Masahiro Yamada Date: Tue, 22 Oct 2019 13:37:47 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] scripts/nsdeps: use alternative sed delimiter To: Jessica Yu Cc: Linux Kernel Mailing List , Matthias Maennich Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Oct 22, 2019 at 1:05 AM Jessica Yu wrote: > > When doing an out of tree build with O=, the nsdeps script constructs > the absolute pathname of the module source file so that it can insert > MODULE_IMPORT_NS statements in the right place. However, ${srctree} > contains an unescaped path to the source tree, which, when used in a sed > substitution, makes sed complain: > > ++ sed 's/[^ ]* *//home/jeyu/jeyu-linux\/&/g' > sed: -e expression #1, char 12: unknown option to `s' > > The sed substitution command 's' ends prematurely with the forward > slashes in the pathname, and sed errors out when it encounters the 'h', > which is an invalid sed substitution option. To avoid escaping forward > slashes in ${srctree}, we can use '|' as an alternative delimiter for > sed to avoid this error. > > Signed-off-by: Jessica Yu > --- > > This is an alternative to my first patch here: > > http://lore.kernel.org/r/20191021145137.31672-1-jeyu@kernel.org > > Matthias suggested using an alternative sed delimiter instead to avoid the > ugly/unreadable ${srctree//\//\\\/} substitution. > > scripts/nsdeps | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/scripts/nsdeps b/scripts/nsdeps > index 3754dac13b31..63da30a33422 100644 > --- a/scripts/nsdeps > +++ b/scripts/nsdeps > @@ -33,7 +33,7 @@ generate_deps() { > if [ ! -f "$ns_deps_file" ]; then return; fi > local mod_source_files=`cat $mod_file | sed -n 1p \ > | sed -e 's/\.o/\.c/g' \ > - | sed "s/[^ ]* */${srctree}\/&/g"` > + | sed "s|[^ ]* *|${srctree}\/&|g"` You no longer need to escape the '/'. s|[^ ]* *|${srctree}/&|g is enough. BTW, connecting multiple sed commands with pipes is not efficient. sed -n 1p | sed -e 's/\.o/\.c/g' can be replaced with sed -n '1s/\.o/\.c/gp' This script can be improved a whole if somebody is interested in the refactoring. > for ns in `cat $ns_deps_file`; do > echo "Adding namespace $ns to module $mod_name (if needed)." > generate_deps_for_ns $ns $mod_source_files > -- > 2.16.4 > -- Best Regards Masahiro Yamada