Contents of file "postforth.4th"

#! /usr/local/postforth/pfkern
( add postscript words to postFORTH; these will be lowercase)

: if ( cf flag - ?) ( true, execute cf; cf may leave something on stack)
 IF ' EXECUTE ,
 ELSE ' DROP ,
 ENDIF ' ;S ,

: ifelse ( cf1 cf2 flag - ?) ( true, execute cf1, else execute cf2)
 IF ' DROP , ' EXECUTE ,
 ELSE ' SWAP , ' DROP , ' EXECUTE ,
 ENDIF ' ;S ,

0 ' TASK ! ( erase previous definition of TASK)

: TASK
 ' ARGC , ' 1 , ' > , IF ( any arg is a file to be read as STDIN)
 ' 1 , ' ARGV , ' 0 , ' 0 ,
 ' OPEN , ( open read-only) ' B/BUF , ' IN , ' READ , ' DROP ,
 ' IN , ' >IN , ' ! , ( zero buffer pointer)
 ' SIGCHLD , ' LIT , ' REAPER @ , ' SIGNAL ,
 ' INTERPRET , ' TAIL , ' >CODE , ' QUIT JMP,
 ELSE ( show banner and launch into normal query-interpret loop)
 ' HELLO ,
 ' SIGCHLD , ' LIT , ' REAPER @ , ' SIGNAL , ( catch zombie processes)
 ' SIGSEGV , ' LIT , ' RESTART @ , ' SIGNAL , ( save session on error)
 ' >CODE , ' QUIT JMP, ( jump to original definition of QUIT)
 ENDIF

' TASK @ ' QUIT BIND !
.S ( let us know if anything left on stack [meaning a bug!])
S" postforth" SAVESYSTEM 0 EXIT