Fix substitution errors with non-bash shells

The scripts has the hashbang for /bin/sh, I assume for  portability
reasons. Some unix systems symlink sh to bash, others like Ubuntu (in my
case) symlink sh to dash or some other basic shell which do not support
the variable substitution. This is used for sending mail at this moment.

For portability reasons I check if we're in a bash shell, if so use the
bash variable substitution as this is available/faster than an external
command. If not as fallback sed will be used, which most of the cases is
present also. Even busybox has some basic sed available. This will
maximize portability usage of this script.
Merge pull request #22 from SerhatG/master

Fix substitution errors with non-bash shells, otherwise sending mail might fail
From upstream: improved the post-processing script to better handle renamed rar-files
Merge pull request #29 from Smenus/master

Upstream Update (from NZBGet 9.1)
Merge remote-tracking branch 'origin/master' into dev