Add paranoid quoting of strings containing variables.

Use $TMPDIR instead of $TMP for temporary files.

Submitted by:	jilles
Add Copyright statement and BSD license per
/usr/share/examples/etc/bsd-style-copyright