ColdGrub1384 / LibTerm

iOS sandboxed terminal with Python, Lua and Clang
https://libterm.app
MIT License
630 stars 115 forks source link

jsc without argument #56

Closed oflebbe closed 4 years ago

oflebbe commented 4 years ago

typing "jsc" crashes libterm

ongyx commented 4 years ago

I also have encountered the same problem. Checking the crash logs, a EXC_BREAKPOINT (SIGTRAP) exception causes the crash. It could be that @ColdGrub1384 accidentally left some sort of breakpoint (for debugging). The crash log file is attached. LibTerm-2020-04-26-142657.txt

ongyx commented 4 years ago

I did more research on this SIGTRAP, and it could be because of this line here, in the main() function for jsc: https://github.com/ColdGrub1384/LibTerm/blob/0d697870c8ea8fd894d49ddf3020101dfcc1131e/LibTerm/Commands/builtins/jsc.swift#L33 argv is empty when there is no arguments, so this is probably an out-of-bounds exception. I suggest an explicit check for when there are no args:

if argv.count == 0 {
    fputs("jsc: Error: no file specified", thread_stderr)
    executionDone = true
}
ColdGrub1384 commented 4 years ago

@oflebbe @onyxware Thanks. I'll fix that