code: def rm(pattern):
      
      paths = glob.glob(pattern)
      for path in paths:
          if path.startswith('.git/'):
              continue
          if os.path.isdir(path):
              def onerror(fun, path, excinfo):
                  exc = excinfo[1]
                  if exc.errno != errno.ENOENT:
                      raise
  
              safe_print("rmdir -f %s" % path)
              shutil.rmtree(path, onerror=onerror)
          else:
              safe_print("rm %s" % path)
              os.remove(path)
docs: Recursively remove a file or dir by pattern.