From ff5fb4bfda8a49feba0d9cd2f74e4b3b5524e779 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me> Date: Wed, 28 Oct 2020 09:17:02 -0400 Subject: [PATCH] added version check function --- charsel | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/charsel b/charsel index d7deba7..7938a1c 100755 --- a/charsel +++ b/charsel @@ -19,7 +19,7 @@ ######################################################################## -VERSION=2.0.7 +VERSION=2.0.8 # Define argument functions function usage() { @@ -33,7 +33,8 @@ A simple terminal character selector -L show installed charfiles without the message -l show installed charfiles -n dont copy character to clipboard, avoids Xclip dependency - -v print version + -V check for updates + -v print current version Exit status: 0 okay, @@ -43,6 +44,18 @@ Exit status: 4 other error" } +function version_check(){ + NEW_VERSION=$(curl -s https://codeberg.org/armaan/charsel/raw/branch/master/charsel \ + | grep VERSION= | tail -c +9) + if [[ $VERSION != $NEW_VERSION ]] + then + echo "an update is available" + else + echo "you are up to date" + fi + +} + CHARDIR=$HOME/.cache/charsel function list() { ls $CHARDIR/charfiles @@ -106,7 +119,7 @@ function validity() { } # Look for arguments -while getopts ":abcdhlLnv" arg +while getopts ":abcdhlLnvV" arg do case ${arg} in a) @@ -143,6 +156,10 @@ do echo "charsel" $VERSION exit 0 ;; + V) + version_check + exit 0 + ;; ?) echo "Invalid option" usage -- 2.39.2