The linear instability of a piecewise uniform shear flow is classically formulated for nondivergent perturbations on a 2D barotropic mean flow with linear shear, bounded on both sides by semi-infinite half-planes where the mean flows are uniform. The problem remains unchanged on the f plane because for nondivergent perturbations the instability is driven by vorticity gradient at the edges of the inner, linear shear region, whereas the vorticity itself does not affect it. The instability of the unbounded case is recovered when the outer regions of uniform velocity are bounded, provided that these regions are at least twice as wide as the inner region of nonzero shear. The numerical calculations demonstrate that this simple scenario is greatly modified when the perturbations' divergence and the variation of the mean height (which geostrophically balances the mean flow) are retained in the governing equations. Although a finite deformation radius exists on the shallow water f plane, the mean vorticity gradient that governs the instability in the nondivergent case remains unchanged, so it is not obvious how the instability is modified by the inclusion of divergence in the numerical solutions of the equations. The results here show that the longwave instability of nondivergent flows is recovered by the numerical solution for divergent flows only when the radius of deformation is at least one order of magnitude larger than the width of the inner uniform shear region. Nevertheless, even at this large radius of deformation both the amplitude of the velocity eigenfunction and the distribution of vorticity and divergence differ significantly from those of nondivergent perturbations and vary strongly in the cross-stream direction. Whereas for nondivergent flows the vorticity and divergence both have a deltafunction structure located at the boundaries of the inner region, in divergent flows they are spread out and attain their maximum away from the boundaries (either in the inner region or in the outer regions) in some range of the mean shear. In contrast to nondivergent flows for which the mean shear is merely a multiplicative factor of the growth rates, in divergent flows new unstable modes exist for sufficiently large mean shear with no shortwave cutoff. This unstable mode is strongly affected by the sign of the mean shear (i.e., the sign of the mean relative vorticity).