Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix missing sha256sum command and print info for fish shell #92

Merged
merged 7 commits into from
Feb 5, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions ponyup-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ BLUE="\e[34m"
RED="\e[31m"
YELLOW="\e[33m"

shasumCommand() {
if command -v sha256sum > /dev/null 2>&1; then
sha256sum "$@"
elif command -v shasum > /dev/null 2>&1; then
shasum --algorithm 256 "$@"
else
echo "No checksum command!"
khaledez marked this conversation as resolved.
Show resolved Hide resolved
exit 1
fi
}

prefix="${default_prefix}"
repository="${default_repository}"
for arg in "$@"; do
Expand Down Expand Up @@ -130,7 +141,7 @@ echo "downloading ${filename}"

curl "${dl_url}" -o "${tmp_dir}/${filename}"

dl_checksum="$(sha256sum "${tmp_dir}/${filename}" | awk '{ print $1 }')"
dl_checksum="$(shasumCommand "${tmp_dir}/${filename}" | awk '{ print $1 }')"

if [ "${dl_checksum}" != "${checksum}" ]; then
printf "%bmchecksum mismatch:\n" "${RED}"
Expand All @@ -149,8 +160,18 @@ printf "%bponyup placed in %b${ponyup_root}/bin%b\n" \
"${BLUE}" "${YELLOW}" "${DEFAULT}"

if ! echo "$PATH" | grep -q "${ponyup_root}/bin"; then
printf "%bYou should add %b${ponyup_root}/bin%b to \$PATH:%b\n" \
"${BLUE}" "${YELLOW}" "${BLUE}" "${DEFAULT}"
printf "%bexport PATH=${ponyup_root}/bin:\$PATH%b\n" \
"${YELLOW}" "${DEFAULT}"
case "${SHELL}" in
*fish)
printf "%bYou should add %b${ponyup_root}/bin%b to \$PATH:%b\n" \
"${BLUE}" "${YELLOW}" "${BLUE}" "${DEFAULT}"
printf "%bset -g fish_user_paths ${ponyup_root}/bin \$fish_user_paths%b\n" \
"${YELLOW}" "${DEFAULT}"
;;
*)
printf "%bYou should add %b${ponyup_root}/bin%b to \$PATH:%b\n" \
"${BLUE}" "${YELLOW}" "${BLUE}" "${DEFAULT}"
printf "%bexport PATH=${ponyup_root}/bin:\$PATH%b\n" \
"${YELLOW}" "${DEFAULT}"
;;
esac
fi