all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#62406: “! failing-command” pattern in shell tests is wrong
@ 2023-03-23 16:00 Ludovic Courtès
  2023-03-23 18:53 ` Eric Bavier
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ludovic Courtès @ 2023-03-23 16:00 UTC (permalink / raw)
  To: 62406; +Cc: Eric Bavier

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’.




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-04-20  5:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-23 16:00 bug#62406: “! failing-command” pattern in shell tests is wrong Ludovic Courtès
2023-03-23 18:53 ` 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

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.