1 USING: kernel parser words continuations namespaces debugger
2 sequences combinators splitting prettyprint system io io.files
3 io.pathnames io.launcher io.directories io.encodings.utf8 io.pipes
4 sequences.deep accessors multi-methods newfx shell.parser
5 combinators.short-circuit eval environment ;
8 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12 [ drop home set-current-directory ]
13 [ first set-current-directory ]
16 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
23 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25 : swords ( -- seq ) { "cd" "pwd" } ;
27 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
29 GENERIC: expand ( expr -- expr )
31 METHOD: expand { single-quoted-expr } expr>> ;
33 METHOD: expand { double-quoted-expr } expr>> ;
35 METHOD: expand { variable-expr } expr>> os-env ;
37 METHOD: expand { glob-expr }
40 [ drop current-directory get directory-files ]
44 METHOD: expand { factor-expr } expr>> eval unparse ;
48 METHOD: expand { back-quoted-expr }
58 METHOD: expand { object } ;
60 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
62 : expansion ( command -- command ) [ expand ] map flatten ;
64 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
66 : run-sword ( basic-expr -- )
67 command>> expansion unclip "shell" lookup execute ;
69 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
71 : run-foreground ( process -- )
72 [ try-process ] [ print-error drop ] recover ;
74 : run-background ( process -- ) run-detached drop ;
76 : run-basic-expr ( basic-expr -- )
78 over command>> expansion >>command
80 over stdout>> >>stdout
86 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
88 : basic-chant ( basic-expr -- )
89 dup command>> first swords member-of?
94 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
96 : pipeline-chant ( pipeline-chant -- ) commands>> run-pipeline drop ;
98 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
106 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
109 current-directory get write
113 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
117 : handle ( input -- )
119 { [ dup f = ] [ drop ] }
120 { [ dup "exit" = ] [ drop ] }
121 { [ dup "" = ] [ drop shell ] }
122 { [ dup expr ] [ expr chant shell ] }
123 { [ t ] [ drop "ix: ignoring input" print shell ] }
127 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
134 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
138 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!