Role of shear in general-relativistic cosmological and stellar models