diff options
Diffstat (limited to 'HACKING/code-quality.md')
-rw-r--r-- | HACKING/code-quality.md | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/HACKING/code-quality.md b/HACKING/code-quality.md index f296621..06f301d 100644 --- a/HACKING/code-quality.md +++ b/HACKING/code-quality.md @@ -43,15 +43,6 @@ checked because of it. Use `set -u` if you can; it makes using an unset variable an error. - If a variable not being set is valid (perhaps a configuration option), use `${var:-}` when accessing it to suppress the error. - - An empty array counts as unset, so if you have an array that may be - empty, use `${var+"${var[@]}"}` (don't put quotes around the outer - pair of braces) to only access it if it's non-empty. - - The reason for this is that a normal string variable is basically - an array with length=1; an unset variable looks like an array - with length=0. Weird stuff. - - Actually, that was only true in Bash <4.4; but since the change - wasn't mentioned in the NEWS, I suspect that a subsequent version - will revert to the pre-4.4 behavior. In the shebang, use `#!/usr/bin/env bash`. This allows us to not hardcode the location of bash (I'm not sure why this is useful for @@ -85,7 +76,7 @@ guidelines They're pretty good, and cover most of the "gotcha's" about Bash syntax. Though, it mentions but discourages the use of Bash 3 features... why? Who still uses Bash 2? For libretools, you should -feel free to use Bash 4 features! +feel free to use Bash 4.4 features! I wrote an article on Bash arrays <https://lukeshu.com/blog/bash-arrays.html>. A lot of people think |