mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-21 17:21:14 -03:00
[docs] Add test example to tutorial
As stated in https://stackoverflow.com/questions/48653771/fishshell-checking-equvalancy-like-does-in-most-languages, we didn't have one of those, and `test` is a relatively important part of plenty of `if`s.
This commit is contained in:
@@ -450,6 +450,22 @@ else
|
||||
end
|
||||
\endfish
|
||||
|
||||
To check string, number or file properties, use <a href="commands.html#test">test</a>, like
|
||||
|
||||
\fish{cli-dark}
|
||||
if test "$fish" = "flounder"
|
||||
echo FLOUNDER
|
||||
end
|
||||
|
||||
# or
|
||||
|
||||
if test "$number" -gt 5
|
||||
echo $number is greater than five
|
||||
else
|
||||
echo $number is five or less
|
||||
end
|
||||
\endfish
|
||||
|
||||
<a href="#tut_combiners">Combiners</a> can also be used to make more complex conditions, like
|
||||
|
||||
\fish
|
||||
|
||||
Reference in New Issue
Block a user