Erlang basics · Lesson 30 (open contents)
Package the edge and leave clues
If a command prints usage but exits with status 0, how will automation interpret it?
Before running: In a scratch directory's erl run {ok, nb_cli} = c(nb_cli), ok = escript:create("nb_cli.escript", [shebang, {beam, "nb_cli.beam"}]). After both succeed, open another system terminal in the same directory and run escript nb_cli.escript, then echo $?. Run main/1 only in the subprocess, not directly in your current erl. Create the fixture with ok = file:write_file("report.txt", <<"hello beam\nagain\n">>). Recompile and repackage after edits.
PredictWill launching with no arguments exit with 0, 1, or 2?
These are fixed example results. This page does not execute code on your computer. Full project examples and reference material are on the deeper page.
Used here: Lesson 15 · Choose with patterns, guards, and errorsLesson 18 · Return success or failure as dataLesson 19 · Read and write one file safelyLesson 25 · Shape builds and make a command
Go deeper: full examples, original exercises and further reading →