From: Martin Castillo <castilma@uni-bremen.de>
To: "Ludovic Courtès" <ludo@gnu.org>, 62406@debbugs.gnu.org
Cc: Eric Bavier <bavier@posteo.net>
Subject: bug#62406: “! failing-command” pattern in shell tests is wrong
Date: Sun, 26 Mar 2023 20:16:38 +0200 [thread overview]
Message-ID: <7d5754f3-86e8-4be5-ccb6-689d4d29a8d7@uni-bremen.de> (raw)
In-Reply-To: <87y1nn790x.fsf@inria.fr>
Hi,
Am 23.03.23 um 17:00 schrieb Ludovic Courtès:> 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.
the documentation on `-e` says:
-e Exit immediately if a pipeline (which may consist of a
single simple command), a list, or a compound command
(see SHELL GRAMMAR above), exits with a non-zero status.
The shell does not exit [...] if the
command's return value is being inverted with !.
I have no idea what might be the rationale for that.
next prev parent reply other threads:[~2023-03-26 20:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7d5754f3-86e8-4be5-ccb6-689d4d29a8d7@uni-bremen.de \
--to=castilma@uni-bremen.de \
--cc=62406@debbugs.gnu.org \
--cc=bavier@posteo.net \
--cc=ludo@gnu.org \
/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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
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).