mirror of
https://github.com/inspec/inspec
synced 2024-11-10 23:24:18 +00:00
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:
commit
bc15c857b5
1 changed files with 4 additions and 11 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue