From patchwork Wed Jan 19 12:31:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 50230 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 740B53858029 for ; Wed, 19 Jan 2022 12:31:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 740B53858029 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1642595509; bh=kthvSPEiY/0bnvb9bO9On89Vb65n+I91F/Nr2nhNVLY=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ttcwjHrJmg0nsBlh6qORK15KCa0PamxhbtlRLjVNeOwZqE/pgpFVl9uyH3dXNkI/L Qdey/p1Do9TsQYXn03vedFb/IMVCRjZyV+EtxakLqoXl8lBemf6dMnr2IGpmsCZgGf rhsb7Kl0KuzRk2f8TMG9nyWZ6MMZP2MgXQZ8iggI= X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by sourceware.org (Postfix) with ESMTP id D08B83858C27 for ; Wed, 19 Jan 2022 12:31:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D08B83858C27 Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 820FC2970; Wed, 19 Jan 2022 13:31:36 +0100 (CET) Date: Wed, 19 Jan 2022 13:31:35 +0100 To: "Frank Ch. Eigler" Subject: [PATCH v2] config: simplify profile.*sh.in Message-ID: <20220119123135.kb76gutv42itxant@tarta.nabijaczleweli.xyz> References: <20220117162219.fqt7heu4j67fzq35@tarta.nabijaczleweli.xyz> <20220118161328.GB21016@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220118161328.GB21016@redhat.com> User-Agent: NeoMutt/20211029 X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FROM_SUSPICIOUS_NTLD, GIT_PATCH_0, KAM_INFOUSMEBIZ, PDS_OTHER_BAD_TLD, PDS_RDNS_DYNAMIC_FP, RDNS_DYNAMIC, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?b?0L3QsNCxIHZpYSBFbGZ1dGlscy1kZXZlbA==?= From: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= Reply-To: =?utf-8?b?0L3QsNCx?= Cc: elfutils-devel@sourceware.org Errors-To: elfutils-devel-bounces+patchwork=sourceware.org@sourceware.org Sender: "Elfutils-devel" Hi! On Tue, Jan 18, 2022 at 11:13:28AM -0500, Frank Ch. Eigler wrote: > You mean "prefix=@prefix@". And it's not needless, > because @sysconfdir@ often expands to "$prefix/something", > which requires a prefix var to be set for evaluation. I did, and yeah, that's right. Guess it was so outlandish that I completely missed it. Dropped. > > 2. Simplify needless sh -c "cat glob 2>/dev/null" > > into cat glob 2>/dev/null > This is not needless, but I forget the exact details. It probably has > to do with the $prefix expansion just above, or perhaps glob > non-matching error handling. Well, no, as-written, it is needless. It's also incorrect, since it's subject to word-splitting (=> a broken glob) again. But, yeah, turns out csh does have "glob non-matching error handing", which is both news to me and a blast from a V3-era past. That being said, it was also broken, because under csh false | cat fails, for some inexplicable reason, and if the glob "fails", so does cat, so so does sh. I've restored it, in a fashion that isn't subject to re-splitting, and actually protects -e mode, for csh. v2 scissor-patch below. Please keep me in CC, as I'm not subscribed, наб -- >8 -- 1. Simplify needless sh -c "cat glob 2>/dev/null" into cat glob 2>/dev/null under sh and fix re-expansion/-e protection under csh 2. Use $( instead of ` under sh 3. Assign to D_U directly and either export it or unset it Signed-off-by: Ahelenia Ziemiańska --- config/profile.csh.in | 10 +++++----- config/profile.sh.in | 9 ++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/config/profile.csh.in b/config/profile.csh.in index 01f7c2f2..012e243a 100644 --- a/config/profile.csh.in +++ b/config/profile.csh.in @@ -1,4 +1,3 @@ - # $HOME/.login* or similar files may first set $DEBUGINFOD_URLS. # If $DEBUGINFOD_URLS is not set there, we set it from system *.url files. # $HOME/.*rc or similar files may then amend $DEBUGINFOD_URLS. @@ -7,10 +6,11 @@ if (! $?DEBUGINFOD_URLS) then set prefix="@prefix@" - set debuginfod_urls=`sh -c "cat @sysconfdir@/debuginfod/*.urls 2>/dev/null" | tr '\n' ' '` - if ( "$debuginfod_urls" != "" ) then - setenv DEBUGINFOD_URLS "$debuginfod_urls" + set DEBUGINFOD_URLS=`sh -c 'cat "$0"/*.urls; :' "@sysconfdir@/debuginfod" 2>/dev/null | tr '\n' ' '` + if ( "$DEBUGINFOD_URLS" != "" ) then + setenv DEBUGINFOD_URLS "$DEBUGINFOD_URLS" + else + unset DEBUGINFOD_URLS endif - unset debuginfod_urls unset prefix endif diff --git a/config/profile.sh.in b/config/profile.sh.in index afce3963..bad20b1e 100644 --- a/config/profile.sh.in +++ b/config/profile.sh.in @@ -1,4 +1,3 @@ - # $HOME/.profile* or similar files may first set $DEBUGINFOD_URLS. # If $DEBUGINFOD_URLS is not set there, we set it from system *.url files. # $HOME/.*rc or similar files may then amend $DEBUGINFOD_URLS. @@ -7,11 +6,7 @@ if [ -z "$DEBUGINFOD_URLS" ]; then prefix="@prefix@" - debuginfod_urls=`sh -c "cat @sysconfdir@/debuginfod/*.urls 2>/dev/null" | tr '\n' ' '` - if [ -n "$debuginfod_urls" ]; then - DEBUGINFOD_URLS="$debuginfod_urls" - export DEBUGINFOD_URLS - fi - unset debuginfod_urls + DEBUGINFOD_URLS=$(cat "@sysconfdir@/debuginfod"/*.urls 2>/dev/null | tr '\n' ' ') + [ -n "$DEBUGINFOD_URLS" ] && export DEBUGINFOD_URLS || unset DEBUGINFOD_URLS unset prefix fi