Skip to content

Instantly share code, notes, and snippets.

@albertsj1
Created November 12, 2009 21:41
Show Gist options
  • Save albertsj1/233307 to your computer and use it in GitHub Desktop.
Save albertsj1/233307 to your computer and use it in GitHub Desktop.
this is the error I get.
/srv/chef/cookbooks/system/libraries/add_env_var.rb:1:in `system': wrong number of arguments (ArgumentError)
Module system
def add_env_var(variable, path)
envfile = "/etc/profile.d/99generic.sh"
foundvar = false
arr = IO.readlines( envfile ) if File::exists?( envfile )
length = arr.length - 1
for i in 0..length
if arr[i][variable] then
line = arr[i].chomp.split( '=' )
paths = line[1].split( ':' ) << path
arr[i] = line[0] + "=" + paths.uniq.join( ':' ) + "\n"
foundvar = true
break
end
end
if !foundvar then
arr << "export #{variable}=#{path}"
end
aFile = File.new( envfile, "w" )
aFile.syswrite( "#{arr.flatten}" )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment