docs: update

This commit is contained in:
Dylan Araps
2018-06-13 12:44:07 +10:00
parent bb6afaa667
commit 65235275ba

View File

@@ -31,6 +31,8 @@ scripts and not full blown utilities.
* [Strings](#strings) * [Strings](#strings)
* [Get the directory name of a file path.](#get-the-directory-name-of-a-file-path) * [Get the directory name of a file path.](#get-the-directory-name-of-a-file-path)
* [Trim quotes from a string.](#trim-quotes-from-a-string) * [Trim quotes from a string.](#trim-quotes-from-a-string)
* [Arrays](#arrays)
* [Reverse an array.](#reverse-an-array)
* [Colors](#colors) * [Colors](#colors)
* [Convert a hex color to RGB.](#convert-a-hex-color-to-rgb) * [Convert a hex color to RGB.](#convert-a-hex-color-to-rgb)
* [Convert an RGB color to hex.](#convert-an-rgb-color-to-hex) * [Convert an RGB color to hex.](#convert-an-rgb-color-to-hex)
@@ -110,6 +112,25 @@ trim_quotes() {
} }
``` ```
## Arrays
### Reverse an array.
Enabling `extdebug` allows access to the `BASH_ARGV` array which stores
the current functions arguments in reverse.
```sh
reverse_array() {
# Usage: reverse_array "array"
# reverse_array 1 2 3 4 5 6
shopt -s extdebug
f()(printf "%s " "${BASH_ARGV[@]}"); f "$@"
shopt -u extdebug
printf '\n'
}
```
## Colors ## Colors
### Convert a hex color to RGB. ### Convert a hex color to RGB.