Created
April 15, 2014 14:10
-
-
Save thomasjo/10735888 to your computer and use it in GitHub Desktop.
Command substitution issue?
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
# This doesn't work together with bats stub as defined in ruby-build | |
compute_sha2() { | |
if type shasum &>/dev/null; then | |
local output="$(shasum -a 256 -b)" | |
echo "${output% *}" | |
elif type openssl &>/dev/null; then | |
local output="$(openssl dgst -sha256)" | |
echo "${output##* }" | |
elif type sha256sum &>/dev/null; then | |
local output="$(sha256sum --quiet)" | |
echo "${output% *}" | |
else | |
return 1 | |
fi | |
} | |
# This works in bats when `shasum` is stubbed, but breaks against | |
# the real binary because the output is "noisy"... | |
compute_sha2() { | |
if type shasum &>/dev/null; then | |
shasum -a 256 -b | |
elif type openssl &>/dev/null; then | |
local output="$(openssl dgst -sha256)" | |
echo "${output##* }" | |
elif type sha256sum &>/dev/null; then | |
local output="$(sha256sum --quiet)" | |
echo "${output% *}" | |
else | |
return 1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment