File:  [gforth] / gforth / script.fs
Revision 1.1: download - view: text, annotated - select for diffs
Sat Dec 1 20:33:14 2001 UTC (17 years, 10 months ago) by pazsan
Branches: MAIN
CVS tags: HEAD
Fixed popen access type (*not binary*)
Fixed some bugs in proxy.fs
Added scripting support

    1: \ scripting extensions
    2: 
    3: : sh-eval ( addr u -- )
    4:     \G evaluate string + rest of command line
    5:     2dup 2>r >in @ >r negate
    6:     source >in @ 1- /string + c@ bl <> + >in +! drop sh
    7:     $? IF  r> >in ! 2r> defers interpreter-notfound
    8:     ELSE  rdrop 2rdrop  THEN ;
    9: ' sh-eval IS interpreter-notfound
   10: 
   11: 2Variable sh$  0. sh$ 2!
   12: : sh-get ( addr u -- addr' u' )
   13:     \G open command addr u, and read in the result
   14:     sh$ free-mem-var
   15:     r/o open-pipe throw dup >r slurp-fid
   16:     r> close-pipe throw to $? 2dup sh$ 2! ;
   17: 
   18: :noname '` parse sh-get ;
   19: :noname '` parse postpone SLiteral postpone sh-get ;
   20: interpret/compile: s`

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>