Skip to main content

src/aws@internal@os_process.erl

-module(aws@internal@os_process).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/aws/internal/os_process.gleam").
-export([run/2]).

-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.

?MODULEDOC(
    " Run an external command and capture its stdout + exit status. Used by\n"
    " the credential-process provider; not a general-purpose subprocess\n"
    " library. Arguments are passed as an explicit list (no shell), so there\n"
    " is no shell-injection surface on the call side.\n"
).

-file("src/aws/internal/os_process.gleam", 10).
?DOC(
    " Run `command` with the given argument list. Returns the exit code paired\n"
    " with the captured combined stdout + stderr on success, or `Error(Nil)` if\n"
    " the executable could not be located or launched.\n"
).
-spec run(binary(), list(binary())) -> {ok, {integer(), bitstring()}} |
    {error, nil}.
run(Command, Args) ->
    aws_ffi:run_process(Command, Args).