From: Mark Felder Date: Thu, 14 Jan 2021 22:58:18 +0000 (-0600) Subject: Just validate command is in PATH; forking a shell is wasteful X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=8d6e9b25a416c0ccc551f94550071968cb76a09c;p=akkoma Just validate command is in PATH; forking a shell is wasteful --- 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"