Compare commits

...

3 Commits

Author SHA1 Message Date
yosh 1253d60e45 better diagnostic output 2024-02-02 17:33:25 -05:00
yosh 9fbbc2fbb6 don't bother with symlinks when updating 2024-02-02 17:28:08 -05:00
yosh 66ffa456eb aaaaaa why I use printf and not errecho for those 2024-02-02 12:48:50 -05:00
1 changed files with 14 additions and 6 deletions

View File

@ -8,8 +8,6 @@ set -euf
BN="${0##*/}"
NL='
'
export POSIXLY_CORRECT=1
if [ -n "${NO_COLOR:-}" ]; then
RED="" GREEN="" YELLOW="" RESET=""
fi
@ -40,17 +38,27 @@ trap "cleanup" INT HUP QUIT TERM EXIT
checkupdate() {
errecho "checking for updates from https://git.unix.dog/yosh/flacconv/src/branch/main/flacconv..."
errecho
tmpupdate=$(mktemp)
curl -s -o "$tmpupdate" 'https://git.unix.dog/yosh/flacconv/raw/branch/main/flacconv' || fail "curl request failed! retry probably"
if cmp "$tmpupdate" "$0"; then
if cmp -s "$tmpupdate" "$0"; then
errecho "you are updated!"
else
printf '%s' "the latest commit differs from the current version. if you use git, please git pull the repo for the update"
printf '%s' "you can see the changes here: https://git.unix.dog/yosh/flacconv/commits/branch/main"
errecho "the latest commit differs from the current version. if you use git, please git pull the repo for the update"
errecho "you can see the changes here: https://git.unix.dog/yosh/flacconv/commits/branch/main"
printf '%s' "if you don't use git, apply update directly? [y/n] " >&2
read -r choice
case "$choice" in
[Yy]) chmod +x "$tmpupdate" && mv -f "$tmpupdate" "$0" && errecho "updated!" || fail "applying update failed! retry probably" ;;
[Yy])
if [ -L "$0" ]; then
errecho "${RED}your flacconv patch is a symbolic link."
errecho "while it is possible to resolve them in a POSIX manner, it's a weird amount of code"
errecho "so I humbly ask that you update it manually"
exit 1
fi
mv -f "$tmpupdate" "$0"
errecho "updated!"
;;
*) errecho "not applying update!" ;;
esac
fi