From 2bc36192b606e38f2c016ce9cb0d2200d680465c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Sat, 8 Jun 2019 17:27:20 +0300 Subject: [PATCH] general: Fix #38 --- README.md | 2 ++ file | 37 +++++++++++++++++++++++++++++++++++++ manuscript/chapter1.txt | 9 ++++++--- 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 file diff --git a/README.md b/README.md index cbe60ad..05d23a8 100644 --- a/README.md +++ b/README.md @@ -294,6 +294,8 @@ is_hex_color "$color" || color="#FFFFFF" ## Split a string on a delimiter +**CAVEAT:** Requires `bash` 4+ + This is an alternative to `cut`, `awk` and other tools. **Example Function:** diff --git a/file b/file new file mode 100644 index 0000000..7ea1e71 --- /dev/null +++ b/file @@ -0,0 +1,37 @@ + +-> Running tests on the Pure Bash Bible.. +----------------------------------------- + ✔ | bar + ✔ | basename + ✔ | count + ✔ | cycle + ✔ | date + ✔ | dirname + ✔ | extract + ✔ | get_functions + ✔ | head + ✔ | hex_to_rgb + ✔ | hex_to_rgb + ✔ | lines + ✔ | lines_loop + ✔ | lower + ✔ | lstrip + ✔ | read_sleep + ✔ | regex + ✖ | remove_array_dups ("5 4 3 2 1" != "1 2 3 4 5") + ✖ | reverse_array ("5 4 3 2 1 5 4 3 2 1" != "5 4 3 2 1") + ✔ | rgb_to_hex + ✔ | rstrip + ✔ | split + ✔ | strip + ✔ | strip_all + ✔ | tail + ✔ | trim_all + ✔ | trim_quotes + ✔ | trim_string + ✔ | upper + ✔ | urldecode + ✔ | urlencode +---------------------------------------- +Completed 31 tests. 29 passed, 2 failed. + diff --git a/manuscript/chapter1.txt b/manuscript/chapter1.txt index a64e4a4..386ca2f 100644 --- a/manuscript/chapter1.txt +++ b/manuscript/chapter1.txt @@ -117,6 +117,8 @@ is_hex_color "$color" || color="#FFFFFF" ## Split a string on a delimiter +**CAVEAT:** Requires `bash` 4+ + This is an alternative to `cut`, `awk` and other tools. **Example Function:** @@ -315,6 +317,7 @@ The Quick Brown ```sh urlencode() { # Usage: urlencode "string" + local LC_ALL=C for (( i = 0; i < ${#1}; i++ )); do : "${1:i:1}" case "$_" in @@ -344,9 +347,9 @@ https%3A%2F%2Fgithub.com%2Fdylanaraps%2Fpure-bash-bible ```sh urldecode() { - # Usage: urldecode "string" - : "${1//+/ }" - printf '%b\n' "${_//%/\\x}" + # Usage: urldecode "string" + : "${1//+/ }" + printf '%b\n' "${_//%/\\x}" } ```