Created
February 24, 2022 20:54
-
-
Save EricCousineau-TRI/c3c074de657d063b772c9fa9b355319f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eux | |
flags=() | |
: "${flags[@]:-}" # bad | |
: "${flags[@]}" # good | |
flags=("thing w/ space" "other.thing") | |
: "${flags[@]:-}" # good | |
: "${flags[@]}" # good | |
: ${flags[@]} # bad (obvs) | |
<<'EOF' | |
$ bash --version | head -n 1 | |
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu) | |
$ ./this_script.sh | |
+ flags=() | |
+ : '' | |
+ : | |
+ flags=("thing w/ space" "other.thing") | |
+ : 'thing w/ space' other.thing | |
+ : 'thing w/ space' other.thing | |
+ : thing w/ space other.thing | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment