handle errors from curl
@@ -16,13 +16,24 @@ else
exit 1
fi
-curl -s https://api.github.com/repos/ducaale/xh/releases/latest \
-| grep -wo "https.*$target.tar.gz" \
-| xargs -n 1 curl -O -sSL
+echo "Detected target: $target"
+
+url=$(curl -sSL https://api.github.com/repos/ducaale/xh/releases/latest | grep -wo -m1 "https://.*$target.tar.gz")
+if ! test "$url"; then
+ echo "Could not find release info"
+ exit 1
+fi
+
+echo "Downloading xh..."
+
+if ! curl -SLO "$url"; then
+ echo "Could not download tarball"
+ exit 1
+fi
tar xzf xh-*
sudo mv xh-*/xh /usr/local/bin/
sudo ln -sf /usr/local/bin/xh /usr/local/bin/xhs
-echo "xh binary location: $(which xh)"
-echo "xh binary version: $(xh --version)"
+echo "$(xh --version) has been installed successfully"
+echo 'Please ensure that /usr/loca/bin is added to your $PATH'
