#!/usr/bin/env osh : : osh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: 2328e64cf08dafcad5d8878cab68408841a29dd9 $ " : : " 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, or patched, release of the shell, as reported " : " in http://v6shell.org/src/LATEST . " : : " Exit w/ zero status (true) if latest, or newer than latest, " : " version. Otherwise, exit w/ 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 / ; chdir $d'' : : " Fetch LATEST w/ wget, curl, lynx, or an ftp utility w/ HTTP support. " : : WGET if ! { fd2 which wget >/dev/null } goto CURL wget -q http://v6shell.org/src/LATEST goto JUMP : CURL if ! { fd2 which curl >/dev/null } goto LYNX curl -s http://v6shell.org/src/LATEST >LATEST goto JUMP : LYNX if ! { fd2 which lynx >/dev/null } goto FTP lynx -dump http://v6shell.org/src/LATEST >LATEST goto JUMP : FTP if ! { fd2 which ftp >/dev/null } goto ERR1 ftp http://v6shell.org/src/LATEST >/dev/null : fallthrough : JUMP if ! -s LATEST goto ERR2 : fallthrough : : " Create and execute comparison scripts. " : : VC ( \ 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 VersionCompare : PC head -7 >PatchCompare ; goto PC1 echo $v ^ grep -- '-p[1-9]' >/dev/null if $s = 1 echo false >VersionIsPatched head -1 /dev/null if $s = 1 echo false >LatestIsPatched if ! { osh VersionIsPatched } -a ! { osh LatestIsPatched } exit if { osh VersionIsPatched } -a ! { osh LatestIsPatched } exit if ! { osh VersionIsPatched } -a { osh LatestIsPatched } if { exit } false : PC1 ( \ echo -n 'intcmp ' ; \ echo $v ^ sed -n 's/^.*-p\([1-9]\)$/\1/p' ^ tr -d \\n ; \ echo -n ' -ge ' ; \ head -1 >PatchCompare : ILON head -8 >IsLatestOrNewer ; goto EXEC if X$v = X -o X$v = Xv if { exit } false if X$v = Xosh-current exit if ! { osh VersionCompare } if { exit } false if { expr //$v : '//.*-current' >/dev/null } exit if { expr //$v : '//.*-beta[1-9]' >/dev/null } exit if ! { osh PatchCompare } if { exit } false if { osh PatchCompare } exit perror oshlatest '"IsLatestOrNewer: Unexpected condition"' ; kill -9 $$ : EXEC if { osh IsLatestOrNewer } goto TRUE which osh ^ tr -d \\n ; echo : $v: Outdated ; echo ; cat