use mktemp instead of deleting existing files
also sysmlinks xhs
#!/bin/sh
-cd /tmp/
+temp_dir=$(mktemp -d /tmp/xh.XXXXXXXX)
+cd $temp_dir
if [ "$(uname -s)" = "Darwin" ] && [ "$(uname -m)" = "x86_64" ]; then
target="x86_64-apple-darwin"
@@ -15,20 +16,13 @@ else
exit 1
fi
-rm -rf xh*
-
curl -s https://api.github.com/repos/ducaale/xh/releases/latest \
| grep -wo "https.*$target.tar.gz" \
-| wget -qi -
-
-tarball="$(find . -name "xh*$target.tar.gz")"
-tar -xzf $tarball --strip-components=1
-
-chmod +x xh
-sudo mv xh /usr/local/bin/
+| xargs -n 1 curl -O -sSL
-location="$(which xh)"
-echo "xh binary location: $location"
+tar xzf xh-*
+sudo mv xh-*/xh /usr/local/bin/
+sudo ln -s /usr/local/bin/xh /usr/local/bin/xhs
-version="$(xh --version)"
-echo "xh binary version: $version"
+echo "xh binary location: $(which xh)"
+echo "xh binary version: $(xh --version)"
