#!/usr/bin/env osh : : osh - " Force sh(1), csh(1), and other shells to exit w/ error! " <'' ;;; : : " @(#)$Id: 32f9e7cf9259254c6d78aae156cb9559cc210585 $ " : : " The author of this file, J.A. Neitzel , " : " hereby grants it to the public domain. " : trap '' 13 ; umask 77 : >>$0'' <'' ; : >>$1'' <'' ; : >>$2'' <'' ; killer $0 history if \( \ $# = 0 -o X$1 = X-l -o X$1 = X-n -o X$1 = X-p \ \) -a ! \( \ -f $h/.osh.history -a -r $h/.osh.history -a -w $h/.osh.history \ \) if { exit } perror $0 $h/.osh.history'": cannot open"' if $# = 0 goto -a if \( \( X$1 = X-c -o X$1 = X-l -o X$1 = X-r \) -a $# = 1 \) -o \ \( \( X$1 = X-n -o X$1 = X-p \) -a $# = 2 -a X$2 != X \) goto $1 if X$1 = X-h -a $# = 1 goto $1 if { exit } \ pusage $0 '"[-c | -h | -l | -n number1[,number2] | -p pattern | -r]"' : -a wc -l <$h/.osh.history | tr -d ' \t' | \ sed 's,.*,expr & \\>= 1 >/dev/null,' | osh if $? != 0 if { exit } false echo 'Number Command Line' ; echo '------ ------------' fd2 -f /dev/null ncat <$h/.osh.history ; exit : -c ( : ) >$h/.osh.history ; exit : -h perror $0 '"Formatting history help..."' if ! { printenv PAGER } goto more-s >/dev/null printenv PAGER | wc -c | tr -d ' \t' | grep '^1$' >/dev/null if $? = 0 goto more-s printenv PAGER | sed 's,.*,exec & '$0'.help,' | osh ; exit : more-s more -s $0.help ; exit : -l wc -l <$h/.osh.history | tr -d ' \t' | \ sed 's,.*,expr & \\>= 11 >/dev/null,' | osh if $? != 0 if { exit } false echo 'Number Command Line' ; echo '------ ------------' ncat <$h/.osh.history | tail -11 | head -10 ; exit : -n fd2 -f /dev/null \ ncat <$h/.osh.history | fd2 -f /dev/null -- sed -n $2p | \ wc -l | tr -d ' \t' | grep '^0$' >/dev/null if $? = 0 if { exit } false echo 'Number Command Line' ; echo '------ ------------' ncat <$h/.osh.history | sed -n $2p ; exit : -p ncat <$h/.osh.history | egrep -- $2 | grep -v 'history -p' | \ wc -l | tr -d ' \t' | grep '^0$' >/dev/null if $? = 0 if { exit } false echo 'Number Command Line' ; echo '------ ------------' ncat <$h/.osh.history | egrep -- $2 | grep -v 'history -p' ; exit : -r rm -f $h/.osh.history