Update sample scripts in plugin docs for best practices conformance

- Use `printf %q` to quote arguments to survive expansion by the remote
  shell (started by ssh) unharmed.
- Quote all local parameter expansions to prevent contents from being
  word-split and glob-expanded.
- Replace use of external tool `basename` with a parameter expansion
  (shell builtin; no fork/wait overhead)
- Do not use `exec` on a command for which additional commands are
  expected to be run in the same shell. (`exec` replaces the current
  process, and does not return).
- Move assignments from `$1` and `shift`s onto the same line for easier
  reading.
- `exit $?` is redundant; the default behavior of `exit` is to honor
  `$?`.
Merge pull request #297 from charles-dyfis-net/fix-script-examples

Update sample scripts in plugin docs for best practices conformance