[shell mode] Fix empty token bug

Issue #2506