Update facter.sh

Bug fixes on string matching and variable substitution