For new checks and feature suggestions
Suggestion
Given the following script:
#!/bin/bash
set -e
basename "$(curl -fsSL -w '%{url_effective}' -o /dev/null https://github.com/docker/compose/releases/latest)"
It would normally work, but curl could actually fail (such as with command not found). So, for the sake of the example, I will force it to fail by using curl2.
Examples:
$ bash <<'EOF'; echo $?
#!/bin/bash
set -e
basename "$(curl -fsSL -w '%{url_effective}' -o /dev/null https://github.com/docker/compose/releases/latest)"
EOF
v2.0.0
0
With curl2:
$ bash <<'EOF'; echo $?
#!/bin/bash
set -e
basename "$(curl2 -fsSL -w '%{url_effective}' -o /dev/null https://github.com/docker/compose/releases/latest)"
EOF
bash: line 5: curl2: command not found
0
The status code of the latter example is 0 even if the command failed. This is misleading. ShellCheck could advise to be written like so instead:
$ bash <<'EOF'; echo $?
#!/bin/bash
set -e
curl_output="$(curl2 -fsSL -w '%{url_effective}' -o /dev/null https://github.com/docker/compose/releases/latest)"
basename "$curl_output"
EOF
bash: line 5: curl2: command not found
127
References twpayne/chezmoi#1466 (comment)
For new checks and feature suggestions
Suggestion
Given the following script:
It would normally work, but
curlcould actually fail (such as with command not found). So, for the sake of the example, I will force it to fail by usingcurl2.Examples:
With
curl2:The status code of the latter example is 0 even if the command failed. This is misleading. ShellCheck could advise to be written like so instead:
References twpayne/chezmoi#1466 (comment)