Merge pull request #179 from chef/os_env

Merged change 2a868e9f-90a3-4cc6-9c4c-ba510f43ac11

From review branch os_env into master

Signed-off-by: drichter <drichter@chef.io>
This commit is contained in:
chef-delivery 2015-11-01 15:15:42 -08:00
commit bc15c857b5

View file

@ -17,22 +17,15 @@ class OsEnv < Inspec.resource(1)
attr_reader :content
def initialize(env)
@osenv = env
@command_result = inspec.command("su - root -c 'echo $#{env}'")
@content = @command_result.stdout.chomp
cmd = inspec.command("su - root -c 'echo $#{env}'")
@content = cmd.stdout.chomp
@content = nil if cmd.exit_status != 0
end
def split
# -1 is required to catch cases like dir1::dir2:
# where we have a trailing :
@content.split(':', -1)
end
def stderr
@command_result.stderr
end
def exit_status
@command_result.exit_status.to_i
@content.nil? ? [] : @content.split(':', -1)
end
def to_s