D
Dany Cayouette
Greetings,
I'm pretty sure eval/proc/binding needs/can be used to solve my
problem, but I'm having difficulty grasping those concepts.
Given a series of shell scripts (bourne based) containing code such as
FIRST=Dany
LAST='Cayouette'
FULLNAME="$FIRST $LAST"
UID="danyc ($FULLNAME)"
I would like to 'import' those value into a Ruby Hash such that the end
result is something like
{"LAST"=>"Cayouette", "UID"=>"danyc (Dany Cayouette)", "FULLNAME"=>"Dany
Cayouette", "FIRST"=>"Dany"}
So far I have
class Hash
def shparse (file)
File.open(file, "r") do |f|
while line = f.gets
next unless line =~ /^\s*(\w+)=(.*)$/
k = $1
v = $2
self[k] = v
end
end
p self
self
end
end
Which gives me some of the basics, but not the 'expansion' of $VARS.
Any help/input appreciated.
Dany
I'm pretty sure eval/proc/binding needs/can be used to solve my
problem, but I'm having difficulty grasping those concepts.
Given a series of shell scripts (bourne based) containing code such as
FIRST=Dany
LAST='Cayouette'
FULLNAME="$FIRST $LAST"
UID="danyc ($FULLNAME)"
I would like to 'import' those value into a Ruby Hash such that the end
result is something like
{"LAST"=>"Cayouette", "UID"=>"danyc (Dany Cayouette)", "FULLNAME"=>"Dany
Cayouette", "FIRST"=>"Dany"}
So far I have
class Hash
def shparse (file)
File.open(file, "r") do |f|
while line = f.gets
next unless line =~ /^\s*(\w+)=(.*)$/
k = $1
v = $2
self[k] = v
end
end
p self
self
end
end
Which gives me some of the basics, but not the 'expansion' of $VARS.
Any help/input appreciated.
Dany