From 9d221eb692ba6a3610c8545a553e79bf8211cec4 Mon Sep 17 00:00:00 2001 From: Matteo Marescotti Date: Thu, 8 Jul 2021 01:49:40 -0700 Subject: [PATCH] [erlang] Not use --suffix option of mktemp Summary: The --suffix option of mktemp is not available on macos. Changed to rename the temp file created by adding the extension. Reviewed By: skcho Differential Revision: D29587977 fbshipit-source-id: b7a5adda8 --- infer/lib/erlang/erlang.escript | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/infer/lib/erlang/erlang.escript b/infer/lib/erlang/erlang.escript index 8eb9a1100..3d2802ab6 100755 --- a/infer/lib/erlang/erlang.escript +++ b/infer/lib/erlang/erlang.escript @@ -39,7 +39,7 @@ main(Args) -> ]), halt(1) end, - CompiledListPath = string:trim(os:cmd("mktemp --suffix .list")), + CompiledListPath = mktemp(".list"), OutputCmd = case Cmd of ["rebar3" | _] -> @@ -99,6 +99,12 @@ run(Command, Dir) -> {Port, {exit_status, Status}} -> Status end. +mktemp(Suffix) -> + TempFilePath = string:trim(os:cmd("mktemp")), + WithSuffix = TempFilePath ++ Suffix, + os:cmd(io_lib:format("mv ~s ~s", [TempFilePath, WithSuffix])), + WithSuffix. + rebar3(Cmd, CompiledListPath) -> ConfigPaths = [os:getenv("REBAR_CONFIG"), "rebar.config.script", "rebar.config"], Original = @@ -110,7 +116,7 @@ rebar3(Cmd, CompiledListPath) -> Config end, Altered = inject_parse_transform(Original, CompiledListPath), - AltConfigPath = string:trim(os:cmd("mktemp --suffix .script")), + AltConfigPath = mktemp(".script"), file:write_file(AltConfigPath, io_lib:fwrite("~p.~n", [Altered])), io_lib:format("export REBAR_CONFIG=\"~s\"; ~s", [