In ruby Dir.entries takes a path and returns a list of its contents. However it does not deal with paths (strings) which contain Enviroment Variables (envvars), first they need to be expanded.


export DIR=x
export FILE=y.z

Ruby string:

s = "$DIR/test/$FILE"
puts s
=> "$DIR/test/$FILE"

def expand_envvars( in_string )
  return in_string.gsub(/\$(\w+)/) { ENV[$1] }

puts expand_envvars( s )
=> "x/test/y.z"

Based on: