Skip to content

Commit 0ccdbe0

Browse files
rgee0alexellis
authored andcommitted
Add graceful degradation for sha_cmd in get.sh
The earlier choice of using shasum was made for broadest support reasons. However the breadth of support could be broader still by introducing graceful degradation to get.sh. This change defaults the command to be used to sha256sum and reverts to shasum -a 256 if the default isnt found. Signed-off-by: Richard Gee <richard@technologee.co.uk>
1 parent 8ded58d commit 0ccdbe0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

get.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,20 @@ hasCli() {
3030
fi
3131
}
3232

33+
3334
checkHash(){
34-
if [ -x "$(command -v shasum)" ]; then
35+
36+
sha_cmd="sha256sum"
37+
38+
if [ ! -x "$(command -v $sha_cmd)" ]; then
39+
sha_cmd="shasum -a 256"
40+
fi
41+
42+
if [ -x "$(command -v $sha_cmd)" ]; then
3543

3644
targetFileDir=${targetFile%/*}
3745

38-
(cd $targetFileDir && curl -sSL $url.sha256|shasum -c -s)
46+
(cd $targetFileDir && curl -sSL $url.sha256|$sha_cmd -c -s)
3947

4048
if [ "$?" != "0" ]; then
4149
rm $targetFile
@@ -108,7 +116,7 @@ getPackage() {
108116
else
109117

110118
echo
111-
echo "Running as root - Attemping to move faas-cli to /usr/local/bin"
119+
echo "Running as root - Attempting to move faas-cli to /usr/local/bin"
112120

113121
mv $targetFile /usr/local/bin/faas-cli
114122

0 commit comments

Comments
 (0)