Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modification in command resource example #756

Merged
merged 1 commit into from
May 16, 2016
Merged

modification in command resource example #756

merged 1 commit into from
May 16, 2016

Conversation

Anirudh-Gupta
Copy link
Contributor

@Anirudh-Gupta Anirudh-Gupta commented May 16, 2016

Modified the command resource example. The below code fails :

describe command('ls -al /') do
 it { should exist }
end

Instead this should be written :

describe command('ls') do
 it { should exist }
end

@chris-rock
Copy link
Contributor

Thanks @Anirudh-Gupta for highlighting this. The reason for that is the checking for command availability:

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
  warn "`command(#{@command}).exist?` is not suported on your OS: #{inspec.os[:family]}"
  return false
end
res.exit_status.to_i == 0

See https://github.com/chef/inspec/blob/master/lib/resources/command.rb#L46-L55

@chris-rock chris-rock merged commit 23c4bc0 into inspec:master May 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants