2 USING: kernel parser words continuations namespaces debugger
3 sequences combinators splitting prettyprint
4 system io io.files io.launcher io.encodings.utf8 io.pipes sequences.deep
5 accessors multi-methods newfx shell.parser
6 combinators.short-circuit eval environment ;
10 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14 [ drop home set-current-directory ]
15 [ first set-current-directory ]
18 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
27 : swords ( -- seq ) { "cd" "pwd" } ;
29 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31 GENERIC: expand ( expr -- expr )
33 METHOD: expand { single-quoted-expr } expr>> ;
35 METHOD: expand { double-quoted-expr } expr>> ;
37 METHOD: expand { variable-expr } expr>> os-env ;
39 METHOD: expand { glob-expr }
42 [ drop current-directory get directory-files ]
46 METHOD: expand { factor-expr } expr>> eval unparse ;
50 METHOD: expand { back-quoted-expr }
60 METHOD: expand { object } ;
62 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
64 : expansion ( command -- command ) [ expand ] map flatten ;
66 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
68 : run-sword ( basic-expr -- )
69 command>> expansion unclip "shell" lookup execute ;
71 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
73 : run-foreground ( process -- )
74 [ try-process ] [ print-error drop ] recover ;
76 : run-background ( process -- ) run-detached drop ;
78 : run-basic-expr ( basic-expr -- )
80 over command>> expansion >>command
82 over stdout>> >>stdout
88 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
90 : basic-chant ( basic-expr -- )
91 dup command>> first swords member-of?
96 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
98 : pipeline-chant ( pipeline-chant -- ) commands>> run-pipeline drop ;
100 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
108 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
111 current-directory get write
115 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
119 : handle ( input -- )
121 { [ dup f = ] [ drop ] }
122 { [ dup "exit" = ] [ drop ] }
123 { [ dup "" = ] [ drop shell ] }
124 { [ dup expr ] [ expr chant shell ] }
125 { [ t ] [ drop "ix: ignoring input" print shell ] }
129 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
136 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
140 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!