From 8d6e9b25a416c0ccc551f94550071968cb76a09c Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 14 Jan 2021 16:58:18 -0600 Subject: [PATCH] Just validate command is in PATH; forking a shell is wasteful --- lib/pleroma/utils.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/pleroma/utils.ex b/lib/pleroma/utils.ex index fa75a8c99..fae7657d9 100644 --- a/lib/pleroma/utils.ex +++ b/lib/pleroma/utils.ex @@ -30,7 +30,10 @@ defmodule Pleroma.Utils do """ @spec command_available?(String.t()) :: boolean() def command_available?(command) do - match?({_output, 0}, System.cmd("sh", ["-c", "command -v #{command}"])) + case :os.find_executable(String.to_charlist(command)) do + false -> false + _ -> true + end end @doc "creates the uniq temporary directory" -- 2.45.2