GeoGenius.Commands.System (geo_genius v0.2.0)

Copy Markdown View Source

Runs external executables via System.cmd/3.

available?/2 reports whether the executable can be found on the search path; its options are ignored, since nothing about a search-path probe depends on them. run/3 always merges stdout and stderr into one stream -- a caller cannot opt out by passing stderr_to_stdout: false, because the behaviour promises one interleaved output and a host that wants the streams kept apart supplies its own GeoGenius.Command instead.

run/3 never raises. System.cmd/3 raises ErlangError when the executable cannot be found or cannot be executed at all -- the process never starts, so there is no {output, status} pair to report. This rescues that and reports the shell's own conventions for the two cases that matter to a pipeline: 127 for "command not found" (:enoent) and 126 for "found but not executable" (:eacces). A working directory that does not exist is checked before System.cmd/3 runs at all, because the OS failure that would otherwise produce is a bare non-zero status with no output naming what went missing.