File:  [gforth] / gforth / script.fs
Revision 1.5: download - view: text, annotated - select for diffs
Mon Dec 31 19:02:24 2007 UTC (16 years, 3 months ago) by anton
Branches: MAIN
CVS tags: v0-7-0, HEAD
updated copyright year after changing license notice

    1: \ Copyright (C) 2001,2003,2007 Free Software Foundation, Inc.
    2: 
    3: \ This file is part of Gforth.
    4: 
    5: \ Gforth is free software; you can redistribute it and/or
    6: \ modify it under the terms of the GNU General Public License
    7: \ as published by the Free Software Foundation, either version 3
    8: \ of the License, or (at your option) any later version.
    9: 
   10: \ This program is distributed in the hope that it will be useful,
   11: \ but WITHOUT ANY WARRANTY; without even the implied warranty of
   12: \ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13: \ GNU General Public License for more details.
   14: 
   15: \ You should have received a copy of the GNU General Public License
   16: \ along with this program. If not, see http://www.gnu.org/licenses/.
   17: 
   18: \ scripting extensions
   19: 
   20: : sh-eval ( addr u -- )
   21:     \G evaluate string + rest of command line
   22:     2dup 2>r >in @ >r negate
   23:     source >in @ 1- /string + c@ bl <> + >in +! drop sh
   24:     $? IF  r> >in ! 2r> defers interpreter-notfound
   25:     ELSE  rdrop 2rdrop  THEN ;
   26: ' sh-eval IS interpreter-notfound
   27: 
   28: 2Variable sh$  0. sh$ 2!
   29: : sh-get ( addr u -- addr' u' )
   30:     \G open command addr u, and read in the result
   31:     sh$ free-mem-var
   32:     r/o open-pipe throw dup >r slurp-fid
   33:     r> close-pipe throw to $? 2dup sh$ 2! ;
   34: 
   35: :noname '` parse sh-get ;
   36: :noname '` parse postpone SLiteral postpone sh-get ;
   37: interpret/compile: s`

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