shlib.sh: add check_and_set_needsgc function