TRAP LOCAL
SPLIT ARGUMENT$ BY " " TO arg$ SIZE amount
tmp_dir$ = CONCAT$("/tmp/", arg$[0], "/")
tmp_file$ = CONCAT$(arg$[0], ".tmp.bac")
IF amount EQ 2 THEN bacon$ = arg$[1]
ELSE bacon$ = "./bacon"
prompt$ = "-> "
PRINT NL$, "---= Entering BaCon Shell v0.1 using BaCon version ", VERSION$, " with 65535 bytes free ;-) =---", NL$
MAKEDIR tmp_dir$
WHILE TRUE
INPUT prompt$, command$
IF EQUAL(CHOP$(UCASE$(command$)), "EXIT") THEN
END
ELIF LEN(command$) > 0 THEN
IF FILEEXISTS(CONCAT$(tmp_dir$, tmp_file$)) THEN DELETE FILE CONCAT$(tmp_dir$, tmp_file$)
IF FILEEXISTS(CONCAT$(tmp_dir$, tmp_file$, ".c")) THEN DELETE FILE CONCAT$(tmp_dir$, tmp_file$, ".c")
IF FILEEXISTS(CONCAT$(tmp_dir$, tmp_file$, ".h")) THEN DELETE FILE CONCAT$(tmp_dir$, tmp_file$, ".h")
OPEN CONCAT$(tmp_dir$, tmp_file$) FOR WRITING AS tmp_file
WRITELN command$ TO tmp_file
CLOSE FILE tmp_file
result$ = EXEC$(CONCAT$(bacon$, " -d ", tmp_dir$, " ", CONCAT$(tmp_dir$, tmp_file$)))
IF NOT(INSTR(result$, "ready")) THEN
PRINT "? ERROR"
ELSE
SYSTEM CONCAT$(tmp_dir$, LEFT$(tmp_file$, LEN(tmp_file$) - 4))
END IF
END IF
WEND