#!/usr/bin/env osh : : osh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: 9c9ff6d084a2e3af077da58b0e2137f5c904dae5 $ " : : " 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 [-v] " : : " Check for correct usage. " : >>$0'' <'' ; : >>$1'' <'' ; killer $0 oshlatest if $# -ne 0 -a ! \( $# -eq 1 -a X$1 = X-v \) if { exit } pusage $0 '"[-v]"' trap '' 2 3 setenv OSHDIR /tmp/oshlatest-$$ umask 0077 if ! { fd2 which which >/dev/null } if { exit } perror $0 '"which: Not found"' 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'' if $# -ne 1 -a X$1 != X-v goto WGET : : " Be verbose; write shell version to standard output. " : shift if { fd2 -f/dev/null -- osh -c version VersionVerbose } if ! -s VersionVerbose if ! { fd2 -ef/dev/null which uname } \ if { echo $v } goto WGET if ! -s VersionVerbose if { fd2 -ef/dev/null which uname } \ osh -c 'echo -n $v \( ; uname -srm ^ tr -d \\n ; echo \)' if -s VersionVerbose cat /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 'if ' ; \ 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 -10 >PatchCompare ; goto PC1 : set D '-v' ; : " DEBUG " set D '' ; : " NO DEBUG " echo $v ^ grep -- '-p[1-9]' >/dev/null if $? -eq 1 echo false >VersionIsPatched head -1 /dev/null if $? -eq 1 echo false >LatestIsPatched if ! { osh $D VersionIsPatched } -a ! { osh $D LatestIsPatched } exit if { osh $D VersionIsPatched } -a ! { osh $D LatestIsPatched } exit if ! { osh $D VersionIsPatched } -a { osh $D LatestIsPatched } \ if { exit } false : PC1 ( \ echo -n 'if ' ; \ echo $v ^ sed -n 's/^.*-p\([1-9]\)$/\1/p' ^ tr -d \\n ; \ echo -n ' -ge ' ; \ head -1 >PatchCompare : ILON head -10 >IsLatestOrNewer ; goto EXEC : set D '-v' ; : " DEBUG " set D '' ; : " NO DEBUG " if X$v = X -o X$v = Xv if { exit } false if X$v = Xosh-current exit if ! { osh $D VersionCompare } if { exit } false if { expr //$v : '//.*-current' >/dev/null } exit if { expr //$v : '//.*-beta[1-9]' >/dev/null } exit if ! { osh $D PatchCompare } if { exit } false if { osh $D PatchCompare } exit perror oshlatest '"IsLatestOrNewer: Unexpected condition"' ; kill -9 $$ : EXEC : set D '-v' ; : " DEBUG " set D '' ; : " NO DEBUG " if { osh $D IsLatestOrNewer } goto TRUE which osh ^ tr -d \\n ; echo : $v: Outdated ; echo ; cat