Exceptions: Add an exception for ^c
This commit is contained in:
parent
5116918ff2
commit
87982fdcbc
|
@ -35,6 +35,7 @@ type
|
||||||
variable: string
|
variable: string
|
||||||
ShellCommandError = object of ShellError
|
ShellCommandError = object of ShellError
|
||||||
command: string
|
command: string
|
||||||
|
InterruptCtrlC = object of CatchableError
|
||||||
|
|
||||||
# procs for making procedures
|
# procs for making procedures
|
||||||
proc newShellException(msg: string, line=0, col=0, whileExec=""): ref ShellError =
|
proc newShellException(msg: string, line=0, col=0, whileExec=""): ref ShellError =
|
||||||
|
@ -323,4 +324,10 @@ proc eval(cmd: string): string =
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
let stdinstrm = stdin.newFileStream
|
let stdinstrm = stdin.newFileStream
|
||||||
while not stdinstrm.atEnd():
|
while not stdinstrm.atEnd():
|
||||||
stdinstrm.readCommand.execute.echo
|
try:
|
||||||
|
discard stdinstrm.readCommand.execute
|
||||||
|
except ShellError, ShellCommandError, ShellVariableError:
|
||||||
|
let e = getCurrentException()
|
||||||
|
stderr.write(e.msg, "\n")
|
||||||
|
except InterruptCtrlC:
|
||||||
|
continue
|
||||||
|
|
Loading…
Reference in New Issue