mirror of
https://github.com/dylanaraps/pure-sh-bible
synced 2024-06-08 16:52:31 +02:00
docs: update
This commit is contained in:
parent
3988ed31be
commit
a8f03f5ddd
27
README.md
27
README.md
|
@ -70,6 +70,7 @@ See something incorrectly described, buggy or outright wrong? Open an issue or s
|
||||||
* [Miscellaneous](#miscellaneous)
|
* [Miscellaneous](#miscellaneous)
|
||||||
* [ARITHMETIC](#arithmetic-1)
|
* [ARITHMETIC](#arithmetic-1)
|
||||||
* [Ternary Tests](#ternary-tests)
|
* [Ternary Tests](#ternary-tests)
|
||||||
|
* [Check if a number is a float](#check-if-a-number-is-a-float)
|
||||||
* [TRAPS](#traps)
|
* [TRAPS](#traps)
|
||||||
* [Do something on script exit](#do-something-on-script-exit)
|
* [Do something on script exit](#do-something-on-script-exit)
|
||||||
* [Ignore terminal interrupt (CTRL+C, SIGINT)](#ignore-terminal-interrupt-ctrlc-sigint)
|
* [Ignore terminal interrupt (CTRL+C, SIGINT)](#ignore-terminal-interrupt-ctrlc-sigint)
|
||||||
|
@ -802,6 +803,32 @@ For use in `[ ]` `if [ ]; then` and `test`.
|
||||||
var=$((var2 > var ? var2 : var))
|
var=$((var2 > var ? var2 : var))
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Check if a number is a float
|
||||||
|
|
||||||
|
**Example Function:**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
is_float() {
|
||||||
|
# Usage: is_float "number"
|
||||||
|
case $1 in
|
||||||
|
*.*.*|*[!-.0-9]*) ;;
|
||||||
|
*[0-9].[0-9]*) return 0
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Example Usage:**
|
||||||
|
|
||||||
|
```shell
|
||||||
|
$ is_float 1.1 && echo true
|
||||||
|
true
|
||||||
|
|
||||||
|
$ is_float 1 && echo true
|
||||||
|
$
|
||||||
|
```
|
||||||
|
|
||||||
# TRAPS
|
# TRAPS
|
||||||
|
|
||||||
Traps allow a script to execute code on various signals. In [pxltrm](https://github.com/dylanaraps/pxltrm) (*a pixel art editor written in bash*) traps are used to redraw the user interface on window resize. Another use case is cleaning up temporary files on script exit.
|
Traps allow a script to execute code on various signals. In [pxltrm](https://github.com/dylanaraps/pxltrm) (*a pixel art editor written in bash*) traps are used to redraw the user interface on window resize. Another use case is cleaning up temporary files on script exit.
|
||||||
|
|
Loading…
Reference in a new issue