Formation of shell galaxies. II. Nonspherical potentials