Fix that REPL crashes in shell mode on $a<tab> and added a test.
Merge pull request #8995 from dhoegh/shell_completion_fix

Fix that REPL crashes in shell mode on $a<tab>