Skip to content

Instantly share code, notes, and snippets.

@shivam-deepsource
Created September 29, 2022 05:35
Show Gist options
  • Save shivam-deepsource/bd762de254965e178b8ed58ea5fa39d5 to your computer and use it in GitHub Desktop.
Save shivam-deepsource/bd762de254965e178b8ed58ea5fa39d5 to your computer and use it in GitHub Desktop.
askInstall()
{
read -p "Do you wish to install $1 [Y/n]: " answer
answer=${answer:-Y}
if [[ "$answer" == [Yy] ]]; then
cd "$1" || return 1
echo -n "Installing $1: "
chmod a+x "$1"
cp "$1" /usr/local/bin > /dev/null 2>&1 || { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; }
echo "Success"
cd .. || return 1
fi
}
updateTool()
{
if [[ -f /usr/local/bin/$1 ]]; then
usedGithubInstallMethod="1"
cd "$1" || return 1
echo -n "Installing $1: "
chmod a+x "$1"
cp "$1" /usr/local/bin > /dev/null 2>&1 || { echo "Failure"; echo "Error copying file, try running install script as sudo"; exit 1; }
echo "Success"
cd .. || return 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment