shell: remove duplicated code
shell: remove duplicated code

This clean-up seems alright, but someone with better knowledge has to
doublecheck this function. I guess there's a lot of space for clean-up
there.

[pq: looks ok, redone since did not apply after my changes]

Signed-off-by: Pekka Paalanen <6c0263d81461c956d504307112a4ce25eaacc3d1@gmail.com>

giucam/weston,sir-murray/weston,xorgy/weston,sir-murray/weston,krezovic/weston,eyolfson/weston,Tarnyko/weston-xdg_surface_present,Fantu/compositor-spice,mchalupa/weston,kwm81/weston,eyolfson/weston,kwm81/weston,jonnylamb/weston,udoprog/weston,Gnurou/weston,Fantu/compositor-spice,jonnylamb/weston,Gnurou/weston,giucam/weston,krezovic/weston,Fantu/compositor-spice,mchalupa/weston,Tarnyko/weston-xdg_surface_present,xorgy/weston,udoprog/weston