MCPcopy Index your code
hub / github.com/abiosoft/ishell / run

Method run

ishell.go:168–218  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

166}
167
168func (s *Shell) run() {
169shell:
170 for s.Active() {
171 var line []string
172 var err error
173 read := make(chan struct{})
174 go func() {
175 line, err = s.read()
176 read <- struct{}{}
177 }()
178 select {
179 case <-read:
180 break
181 case <-s.haltChan:
182 continue shell
183 }
184
185 if err == io.EOF {
186 if s.eof == nil {
187 fmt.Println("EOF")
188 break
189 }
190 if err := handleEOF(s); err != nil {
191 s.Println("Error:", err)
192 continue
193 }
194 } else if err != nil && err != readline.ErrInterrupt {
195 s.Println("Error:", err)
196 continue
197 }
198
199 if err == readline.ErrInterrupt {
200 // interrupt received
201 err = handleInterrupt(s, line)
202 } else {
203 // reset interrupt counter
204 s.interruptCount = 0
205
206 // normal flow
207 if len(line) == 0 {
208 // no input line
209 continue
210 }
211
212 err = handleInput(s, line)
213 }
214 if err != nil {
215 s.Println("Error:", err)
216 }
217 }
218}
219
220// Active tells if the shell is active. i.e. Start is previously called.
221func (s *Shell) Active() bool {

Callers 2

StartMethod · 0.95
RunMethod · 0.95

Calls 6

ActiveMethod · 0.95
readMethod · 0.95
handleEOFFunction · 0.85
handleInterruptFunction · 0.85
handleInputFunction · 0.85
PrintlnMethod · 0.65

Tested by

no test coverage detected