This is my code for getting all system users:
def get_all_system_users
user_paths = Dir["#{ENV['HOME']}/../*"]
users = user_paths.map { |path| path.split("..")[-1].gsub(/\W/, '') }
users.select { |user| %x{id #{user}}.include?("uid") }
end
The problem is the id #{user} command which returns an output for inexistent users that bubbles all the way, exactly like a puts or pp.
How can I mute it but still evaluate the output of the command?