Improve POSIX compilance
- fix warnings reported by https://www.shellcheck.net/
- fix
sed
script (it was not removing the artificial trailing:
) - fix
unset
-ing ofdeactivate
(in special cases)
sed
script (it was not removing the artificial trailing :
)unset
-ing of deactivate
(in special cases)