@@ -38,25 +38,28 @@ install() {
38
38
curl -L " $url " --output " $filename "
39
39
# Verify file integrity if sha512sum is availible and a hash can be obtained
40
40
if hash sha512sum && sha512_hash=$( curl -Lf " ${url% .tar.gz} .sha512sum" 2> /dev/null) ; then
41
- echo " --> Verfiying file integrity..."
42
- if ! sha512sum -c <<< " ${sha512_hash%% *} ${filename}" ; then
43
- # If the session is interactive, we ask the user whether or not to accept a failed checksum,
44
- # but permissively default to continuing if the session is not interactive or no response is given.
45
- if [[ -v PS1 ]] || [[ $- = * i* ]]; then
46
- while true ; do
47
- read -p " --> File integrity check failed. Continue? ([Y]/n) "
48
- case " $REPLY " in
49
- [yY][eE][sS]|[yY]|' ' ) break ;;
50
- [nN][oO]|[nN]) exit 1 ;;
51
- * ) echo " Invalid input..." ;;
52
- esac
53
- done
54
- else
55
- echo " --> WARNING: File integrity check failed."
41
+ echo " --> Verfiying file integrity..."
42
+ if ! printf ' %s' " ${sha512_hash%% * } ${filename} " | sha512sum -c /dev/stdin; then
43
+ # If stdin is a terminal, we ask whether
44
+ # or not to accept a failed checksum,
45
+ # but otherwise exit.
46
+ if [ -t 0 ]; then
47
+ while true ; do
48
+ printf ' %s' " --> File integrity check failed. Continue? (y/[N]) "
49
+ read -r REPLY
50
+ case " $REPLY " in
51
+ [yY][eE][sS]|[yY]) break ;;
52
+ [nN][oO]|[nN]|' ' ) exit 1 ;;
53
+ * ) echo " Invalid input..." ;;
54
+ esac
55
+ done
56
+ else
57
+ echo " --> ERROR: File integrity check failed." 1>&2
58
+ exit 1
59
+ fi
56
60
fi
57
- fi
58
- else
59
- echo " --> Skipping file integrity check (hash not found)."
61
+ else
62
+ echo " --> Skipping file integrity check (hash not found)."
60
63
fi
61
64
echo " --> Extracting $filename ..."
62
65
tar -xf " $filename "
0 commit comments