Since no one has said it yet, please always use https://www.shellcheck.net/ on your scripts, you don't want to be That Guy https://github.com/ValveSoftware/steam-for-linux/issues/3671
Type-ish – A runtime type checker for bash, in bash
11–19 of 19 posts
Re: Type-ish – A runtime type checker for bash, in bash
#12Since no one has said it yet, please always use https://www.shellcheck.net/ on your scripts, you don't want to be That Guy https://github.com/ValveSoftware/steam-for-linux/issues/3671
Re: Type-ish – A runtime type checker for bash, in bash
#13Earlier quoted context omitted.
Booleans in shell scripts are little more than zero (true) and non-zero (false) exit codes.
Ok, right. But then it should still say either "booleans are just numbers" or "numbers can be interpreted as booleans, i.e. are truthy or falsy".
[[ 0 ]] && echo "hit 0"
[[ 1 ]] && echo "hit 1"
grep -q 127 /etc/hosts && echo "hit grep"
grep -q 128 /etc/hosts || echo "miss grep"Re: Type-ish – A runtime type checker for bash, in bash
#14Re: Type-ish – A runtime type checker for bash, in bash
#15I used to somehow think Bash scripts were ideal given that they were fairly transparent, but I'll take a Go app or Rust program anyday now over something written in shell script. shfmt is an example.
The problem is, they have a tendency to suddenly get horribly intransparent when they grow larger than maybe a few dozen lines.
Re: Type-ish – A runtime type checker for bash, in bash
#16Since no one has said it yet, please always use https://www.shellcheck.net/ on your scripts, you don't want to be That Guy https://github.com/ValveSoftware/steam-for-linux/issues/3671
set -o nounset
You can check variables as many ways you want, just do this too - safety net in case there's an eventual gapRe: Type-ish – A runtime type checker for bash, in bash
#17Since no one has said it yet, please always use https://www.shellcheck.net/ on your scripts, you don't want to be That Guy https://github.com/ValveSoftware/steam-for-linux/issues/3671
I prefer this summary of it, because the original includes stuff like changing IFS (the fields separators) which I agree with the Gist author to not include, because it is a Bad Idea to blindly suggest it universally.
EDIT: This gist:
https://gist.github.com/robin-a-meade/58d60124b88b60816e8349...
Re: Type-ish – A runtime type checker for bash, in bash
#18Re: Type-ish – A runtime type checker for bash, in bash
#19Since no one has said it yet, please always use https://www.shellcheck.net/ on your scripts, you don't want to be That Guy https://github.com/ValveSoftware/steam-for-linux/issues/3671
I would also add dotglob because it’s rarer for me to want only non-hidden files than it is for me to want all files.