q/examples/shell/shell.q

27 lines
317 B
Plaintext

import io
import mem
import sys
main() {
length := 256
command := mem.alloc(length)
loop {
io.write("λ ")
n := io.in(command)
if n <= 0 {
return
}
command[n-1] = 0
pid := sys.fork()
if pid == 0 {
sys.execve(command, 0, 0)
return
}
sys.waitid(idtype.pid, pid, 0, state.exited)
}
}