Shell: Fix internal reference

Spotted by Kamil Dudka.

Also use "double expansion" consistently.
Add support for shell snippets
Shell: Use a snippet for the input validation example

Add self-tests to the snippet code.  Mention that this construct is
bash-specific.

Fixes the broken regular expression spotted by Eric Blake.