all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: 62406@debbugs.gnu.org
Cc: Eric Bavier <bavier@posteo.net>
Subject: bug#62406: “! failing-command” pattern in shell tests is wrong
Date: Thu, 23 Mar 2023 17:00:14 +0100	[thread overview]
Message-ID: <87y1nn790x.fsf@inria.fr> (raw)

In <https://issues.guix.gnu.org/43616> (commit
d8934360d2453a403b5433e71d09188e4ed23b57), we changed:

  if command that should fail; then false; else true; fi

to:

  ! command that should fail

I had reservations back then, and now I know why: :-)

--8<---------------cut here---------------start------------->8---
$ bash -xe -c '! true; true'
+ true
+ true
$ echo $?
0
$ bash -xe -c '! false; true'
+ false
+ true
$ echo $?
0
--8<---------------cut here---------------end--------------->8---

Whether or not the command following the exclamation mark succeeds, the
statement succeeds.  Bummer.

The Bash manual (info "(bash) Pipelines") reads:

  If the reserved word '!' precedes the pipeline, the exit status is the
  logical negation of the exit status as described above.  The shell
  waits for all commands in the pipeline to terminate before returning a
  value.

To me, that means it should work as we thought, but it’s a fact that it
doesn’t.

Thoughts?

Ludo’.




             reply	other threads:[~2023-03-23 16:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23 16:00 Ludovic Courtès [this message]
2023-03-23 18:53 ` bug#62406: “! failing-command” pattern in shell tests is wrong Eric Bavier
2023-03-28 16:21   ` Ludovic Courtès
2023-04-20  5:48     ` Eric Bavier
2023-03-26 18:16 ` Martin Castillo
2023-03-26 18:21 ` Martin Castillo

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=87y1nn790x.fsf@inria.fr \
    --to=ludo@gnu.org \
    --cc=62406@debbugs.gnu.org \
    --cc=bavier@posteo.net \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.