# File lib/rbreadline.rb, line 1242
  def rl_username_completion_function(text, state)
    return nil if RUBY_PLATFORM =~ /mswin|mingw/

      if (state == 0)
        first_char = text[0,1]
        first_char_loc = (first_char == '~' ? 1 : 0)

        username = text[first_char_loc..-1]
        namelen = username.length
        Etc.setpwent()
      end

    while (entry = Etc.getpwent())
      # Null usernames should result in all users as possible completions.
      break if (namelen == 0 || entry.name =~ /^#{username}/ )
    end

    if entry.nil?
      Etc.endpwent()
      return nil
    else
      value = text.dup
      value[first_char_loc..-1] = entry.name

      if (first_char == '~')
        @rl_filename_completion_desired = true
      end

      return (value)
    end
  end