#!/usr/bin/env osh : : osh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: oshlatest.osh 540 2008-11-01 15:56:51Z jneitzel $ " : : " The author of this file, J.A. Neitzel , " : " hereby grants it to the public domain. " : : : " Check the version of the shell running this script against " : " the latest official release of the shell, as reported in " : " http://v6shell.org/src/LATEST . " : : " Exit with a zero status (true) if latest version or current. " : " Otherwise, exit with a non-zero status (false). " : : " usage: oshlatest " : : " Check for correct usage. " : >>$0'' <'' killer $0'' oshlatest if $n != 0 if { exit } pusage $0 sigign + 2 3 setenv OSHDIR /tmp/oshlatest-$$ umask 0077 if { fd2 which . >/dev/null } if { exit } perror $0 '"which: Invalid results"' if ! { fd2 which osh >/dev/null } if { exit } perror $0 '"osh: Not found"' if ! { mkdir $d'' } if { exit } false chdir $d'' : : " Fetch LATEST w/ ftp, lynx, curl, or wget. " : : FTP if ! { fd2 which ftp >/dev/null } goto LYNX ftp http://v6shell.org/src/LATEST >/dev/null goto JUMP : LYNX if ! { fd2 which lynx >/dev/null } goto CURL lynx -dump http://v6shell.org/src/LATEST >LATEST goto JUMP : CURL if ! { fd2 which curl >/dev/null } goto WGET curl -s http://v6shell.org/src/LATEST >LATEST goto JUMP : WGET if ! { fd2 which wget >/dev/null } goto ERR1 wget -q http://v6shell.org/src/LATEST : fallthrough : JUMP if ! -s LATEST goto ERR2 : : " Create and execute `IsLatestOrCurrent' to do the comparison. " : ( \ echo 'if X$v = X -o X$v = Xv if { exit } false' ; \ echo -n 'intcmp ' ; \ echo $v ^ \ sed -n 's/^.*\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\).*$/\1/p' ^ \ tr -d \\n ; echo -n ' -ge ' ; \ head -1 IsLatestOrCurrent : cat