require "boxen/config"

Facter.add("root_encrypted") do
  config = Boxen::Config.load

  def root_encrypted?
    system("/usr/bin/fdesetup isactive /")
    [0, 2].include? $?
  end

  setcode do
    ENV['BOXEN_NO_FDE'] || !config.fde? || root_encrypted? ? 'yes' : 'no'
  end
end

require "boxen/config"

Facter.add("root_encrypted") do
  config = Boxen::Config.load

  def root_encrypted?
    system("/usr/bin/fdesetup isactive /")
    [0, 2].include? $?.exitstatus
  end

  setcode do
    ENV['BOXEN_NO_FDE'] || !config.fde? || root_encrypted? ? 'yes' : 'no'
  end
end

Fix bug in checking exitstatus
Fix bug in checking exitstatus

When fdesetup returns with exit code 2, $? is actually 512 (512 >> 8 == 2). Need to check for $?.exitstatus