From ff66d2f3c1f1ed1f2bfe38ede8746e694b28fcca Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 8 Oct 2017 02:06:48 +0200 Subject: [PATCH] Add more `test` examples, including expression negation Closes #4383 --- doc_src/test.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc_src/test.txt b/doc_src/test.txt index c5aa4b0fb..8fbc8caeb 100644 --- a/doc_src/test.txt +++ b/doc_src/test.txt @@ -139,6 +139,22 @@ if test $status -eq 0 end \endfish +The previous test can likewise be inverted: + +\fish +if test ! $status -eq 0 + echo "Previous command failed" +end +\endfish + +which is logically equivalent to the following: + +\fish +if test $status -ne 0 + echo "Previous command failed" +end +\endfish + \subsection test-standards Standards `test` implements a subset of the IEEE Std 1003.1-2008 (POSIX.1) standard. The following exceptions apply: