helper: Update docs for OS detection helpers

This commit is contained in:
Indrajit Raychaudhuri 2021-05-02 01:00:06 -05:00 committed by Indrajit Raychaudhuri
parent 8a967fc108
commit 5a8bfd5bf5
2 changed files with 10 additions and 5 deletions

View File

@ -13,6 +13,11 @@ Functions
- `is-callable` checks if a name is a command, function, or alias. - `is-callable` checks if a name is a command, function, or alias.
- `is-true` checks a boolean variable for "true". - `is-true` checks a boolean variable for "true".
- `coalesce` prints the first non-empty string in the arguments array. - `coalesce` prints the first non-empty string in the arguments array.
- `is-darwin` checks if running on macOS Darwin.
- `is-linux` checks if running on Linux.
- `is-bsd` checks if running on BSD.
- `is-cygwin` checks if running on Cygwin (Windows).
- `is-termux` checks if running on Termux (Android).
Authors Authors
------- -------

View File

@ -30,27 +30,27 @@ function coalesce {
return 1 return 1
} }
# is true on MacOS Darwin # Checks if running on macOS Darwin.
function is-darwin { function is-darwin {
[[ "$OSTYPE" == darwin* ]] [[ "$OSTYPE" == darwin* ]]
} }
# is true on Linux's # Checks if running on Linux.
function is-linux { function is-linux {
[[ "$OSTYPE" == linux* ]] [[ "$OSTYPE" == linux* ]]
} }
# is true on BSD's # Checks if running on BSD.
function is-bsd { function is-bsd {
[[ "$OSTYPE" == *bsd* ]] [[ "$OSTYPE" == *bsd* ]]
} }
# is true on Cygwin (Windows) # Checks if running on Cygwin (Windows).
function is-cygwin { function is-cygwin {
[[ "$OSTYPE" == cygwin* ]] [[ "$OSTYPE" == cygwin* ]]
} }
# is true on termux (Android) # Checks if running on termux (Android).
function is-termux { function is-termux {
[[ "$OSTYPE" == linux-android ]] [[ "$OSTYPE" == linux-android ]]
} }