From 64d33fac5de3b3a8032302fc04ef141c51714449 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 19 May 2017 18:54:24 +0200 Subject: [PATCH] docs: Improve faq-exit-status Add examples, a mention of `if command` and link to test/if. See #2773. --- doc_src/faq.hdr | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/doc_src/faq.hdr b/doc_src/faq.hdr index 0311cf442..3e8c605f9 100644 --- a/doc_src/faq.hdr +++ b/doc_src/faq.hdr @@ -86,6 +86,26 @@ end Use the `$status` variable. This replaces the `$?` variable used in some other shells. +\fish{cli-dark} +somecommand +if test $status -eq 7 + echo "That's my lucky number!" +end +\endfish + +If you are just interested in success or failure, you can run the command directly as the if-condition: + +\fish{cli-dark} +if somecommand + echo "Command succeeded" +else + echo "Command failed" +end +\endfish + +See the documentation for `test` and `if` for more information. + +Use the `fish_update_completions` command.
\section faq-single-env How do I set an environment variable for just one command?