Shell: add missing null check. Fixes #1711.