[gforth] / gforth / script.fs  

gforth: gforth/script.fs


1 : anton 1.5 \ Copyright (C) 2001,2003,2007 Free Software Foundation, Inc.
2 : anton 1.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 : anton 1.4 \ as published by the Free Software Foundation, either version 3
8 : anton 1.2 \ 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 : anton 1.4 \ along with this program. If not, see http://www.gnu.org/licenses/.
17 : anton 1.2
18 : pazsan 1.1 \ 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`

CVS Admin

Powered by ViewCVS 1.0-dev
(Powered by ViewCVS)

ViewCVS and CVS Help