public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Mark Wielaard <mark@klomp.org>
To: "Dmitry V. Levin" <ldv@strace.io>
Cc: elfutils-devel@sourceware.org
Subject: Re: [PATCH] config: Make sure profile.sh succeeds with set -e and set -o pipefail
Date: Wed, 27 Mar 2024 14:52:29 +0100	[thread overview]
Message-ID: <20240327135229.GC9427@gnu.wildebeest.org> (raw)
In-Reply-To: <20240326225913.GA28349@altlinux.org>

Hi Dmitry,

On Wed, Mar 27, 2024 at 12:59:13AM +0200, Dmitry V. Levin wrote:
> On Tue, Mar 26, 2024 at 09:49:48PM +0100, Mark Wielaard wrote:
> > profile.sh might fail with set -o pipefail because:
> > 
> > cat /dev/null "${prefix}/etc/debuginfod"/*.urls 2>/dev/null | tr '\n' ' '
> > 
> > might fail when there isn't an *.urls file the first command in the
> > pipe fails (the 2>/dev/null is there to hide that failure).
> [...]
> > -    DEBUGINFOD_URLS=$(cat /dev/null "@sysconfdir@/debuginfod"/*.urls 2>/dev/null | tr '\n' ' ')
> > +    DEBUGINFOD_URLS=$(cat /dev/null "@sysconfdir@/debuginfod"/*.urls 2>/dev/null | tr '\n' ' ' || echo -n "")
> 
> The idiomatic expression in this case is ||:

Ah, yes. That is nicer indeed.

Pushed with that change and updated commit message:

commit 0ba2e4aa9945019a8c6db95d27d142b660a63a79 (HEAD -> main, origin/main)
Author: Mark Wielaard <mark@klomp.org>
Date:   Tue Mar 26 21:42:39 2024 +0100

    config: Make sure profile.sh succeeds with set -e and set -o pipefail
    
    profile.sh might fail with set -o pipefail because:
    
    cat /dev/null "${prefix}/etc/debuginfod"/*.urls 2>/dev/null | tr '\n' ' '
    
    might fail when there isn't an *.urls file the first command in the
    pipe fails (the 2>/dev/null is there to hide that failure).
    
    This can be fixed by adding || : at the end.
    
    This works because : always succeeds and  produces no outpur which is
    what the script expects when the command would fail.
    
    Also add a new testcase that runs profile.sh with bout  set -e
    and set -o pipefail.
    
            * config/profile.sh.in: Add || : at end of pipe.
            * tests/run-debuginfod-client-profile.sh: New test.
            * tests/Makefile.am (TESTS): Add run-debuginfod-client-profile.sh.
            (EXTRA_DIST): Likewise.
    
    https://sourceware.org/bugzilla/show_bug.cgi?id=31562
    
    Signed-off-by: Mark Wielaard <mark@klomp.org>

Thanks,

Mark

      reply	other threads:[~2024-03-27 13:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26 20:49 Mark Wielaard
2024-03-26 22:59 ` Dmitry V. Levin
2024-03-27 13:52   ` Mark Wielaard [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240327135229.GC9427@gnu.wildebeest.org \
    --to=mark@klomp.org \
    --cc=elfutils-devel@sourceware.org \
    --cc=ldv@strace.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).