You can import the 'shell.py' library from checkpkg sources and get rid of lines 252-267.