X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/4ff0cc66421194a13fa39742598527cf36c3fa98..f58ca98c9db47aa5ca7f5415fdd658fe3b72d24f:/bin/kercmp diff --git a/bin/kercmp b/bin/kercmp new file mode 100755 index 0000000..af3fcba --- /dev/null +++ b/bin/kercmp @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +version="0.1" + +function usage () +{ + echo "Usage : $0 [options] + + Options: + -h,--help Display this message + -v,--version Display script version" +} + +# Parse arguments +declare -a args +while [[ $# -gt 0 ]]; do + opt="$1" + + case $opt in + -h|--help) usage; exit 0 ;; + -v|--version) echo "$0 -- Version $version"; exit 0 ;; + -q|--quiet) quiet=1 ; shift ;; + -* ) + echo -e "\n Option does not exist : $opt\n" + usage; exit 1 ;; + + *) args+=("$opt"); shift ;; + esac +done + +running=$(uname -r | sed s/-/./) +install=$(pacman -Q linux | cut -d' ' -f2) +vcmp=$(vercmp $running $install) + +((${quiet:=0}==1)) && exit $vcmp + +(($vcmp<0)) && echo "$running older than $install" +(($vcmp>0)) && echo "$running newer than $install" + +exit $vcmp