From d470803c375f7f594f78325f22e1f7038c1e32f4 Mon Sep 17 00:00:00 2001 From: Christoph Hartmann Date: Mon, 2 Nov 2015 12:00:15 +0100 Subject: [PATCH] improve command.exist? for more operating systems --- lib/resources/command.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/resources/command.rb b/lib/resources/command.rb index d1da3b3e8..f8498f4fa 100644 --- a/lib/resources/command.rb +++ b/lib/resources/command.rb @@ -35,7 +35,15 @@ class Cmd < Inspec.resource(1) end def exist? - res = inspec.backend.run_command("type \"#{@command}\" > /dev/null") + if inspec.os.linux? + res = inspec.backend.run_command("bash -c 'type \"#{@command}\"'") + elsif inspec.os.windows? + res = inspec.backend.run_command("where.exe \"#{@command}\"") + elsif inspec.os.unix? + res = inspec.backend.run_command("type \"#{@command}\"") + else + fail "`command(#{@command}).exits?` is not suported on you OS." + end res.exit_status.to_i == 0 end