diff options
author | Roman Perepelitsa <roman.perepelitsa@gmail.com> | 2021-11-02 09:23:57 +0300 |
---|---|---|
committer | Roman Perepelitsa <roman.perepelitsa@gmail.com> | 2021-11-02 09:23:57 +0300 |
commit | e2447322e0be4eddb84196f05952f91fa3c6f37e (patch) | |
tree | 034170029d62bc07d9ad1cc25f3f1ac41abd984f /install | |
parent | 1af638543631f2e7db64829c7412ed007047fa81 (diff) |
Squashed 'gitstatus/' changes from eaf430112..e26996460
e26996460 survive broken shasum
b1825b29a make bash bindings work with nounset
git-subtree-dir: gitstatus
git-subtree-split: e269964607042ef0fdbda2d7af74ef9c8f618cf4
Diffstat (limited to 'install')
-rwxr-xr-x | install | 44 |
1 files changed, 23 insertions, 21 deletions
@@ -304,27 +304,29 @@ END local data_file="$tmpdir"/"$1".tar.gz local hash_file="$tmpdir"/"$1".tar.gz.sha256 local hash= - if command -v shasum >/dev/null 2>/dev/null; then - if run_cmd shasum -b -a 256 -- "$data_file" >"$hash_file"; then - IFS= read -r hash <"$hash_file" || hash= - hash="${hash%% *}" - fi - elif command -v sha256sum >/dev/null 2>/dev/null; then - if run_cmd sha256sum -b -- "$data_file" >"$hash_file"; then - IFS= read -r hash <"$hash_file" || hash= - hash="${hash%% *}" - fi - elif command -v sha256 >/dev/null 2>/dev/null; then - if run_cmd sha256 -- "$data_file" </dev/null >"$hash_file"; then - IFS= read -r hash <"$hash_file" || hash= - # Ignore sha256 output if it's from hashalot. It's incompatible. - if [ ${#hash} -lt 64 ]; then - hash= - else - hash="${hash##* }" - fi - fi - fi + { + command -v shasum >/dev/null 2>/dev/null && + run_cmd shasum -b -a 256 -- "$data_file" >"$hash_file" </dev/null && + IFS= read -r hash <"$hash_file" && + hash="${hash%% *}" && + [ ${#hash} -eq 64 ] + } || { + command -v sha256sum >/dev/null 2>/dev/null && + run_cmd sha256sum -b -- "$data_file" >"$hash_file" </dev/null && + IFS= read -r hash <"$hash_file" && + hash="${hash%% *}" && + [ ${#hash} -eq 64 ] + } || { + # Note: sha256 can be from hashalot. It's incompatible. + # Thankfully, it produces shorter output. + command -v sha256 >/dev/null 2>/dev/null && + run_cmd sha256 -- "$data_file" >"$hash_file" </dev/null && + IFS= read -r hash <"$hash_file" && + hash="${hash##* }" && + [ ${#hash} -eq 64 ] + } || { + hash= + } [ "$1" = 1 -a -z "$hash" -o "$hash" = "$sha256" ] } |