shell.cpp code reduction