File:  [gforth] / gforth / script.fs
Revision 1.2: download - view: text, annotated - select for diffs
Sun Mar 9 12:54:33 2003 UTC (16 years, 7 months ago) by anton
Branches: MAIN
CVS tags: HEAD
added copyright messages to a lot of files
removed some obsolete or non-source files

    1: \ Copyright (C) 2001 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 2
    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, write to the Free Software
   17: \ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
   18: 
   19: \ scripting extensions
   20: 
   21: : sh-eval ( addr u -- )
   22:     \G evaluate string + rest of command line
   23:     2dup 2>r >in @ >r negate
   24:     source >in @ 1- /string + c@ bl <> + >in +! drop sh
   25:     $? IF  r> >in ! 2r> defers interpreter-notfound
   26:     ELSE  rdrop 2rdrop  THEN ;
   27: ' sh-eval IS interpreter-notfound
   28: 
   29: 2Variable sh$  0. sh$ 2!
   30: : sh-get ( addr u -- addr' u' )
   31:     \G open command addr u, and read in the result
   32:     sh$ free-mem-var
   33:     r/o open-pipe throw dup >r slurp-fid
   34:     r> close-pipe throw to $? 2dup sh$ 2! ;
   35: 
   36: :noname '` parse sh-get ;
   37: :noname '` parse postpone SLiteral postpone sh-get ;
   38: interpret/compile: s`

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