Shell script cleanups:
- Add required space to
[ -n ]. - Avoid quote within quote.
- Exit if
cdfails. - Remove
\nwhich is not handled byecho. Remove redundant$in arithmetic variable expression.Use$(command)instead of legacy form`command`.- Arrays are not supported in POSIX
sh. Usebashwhen arrays are used. [ foo -a bar ]is not well defined, use[ foo ] && [ bar ]instead.[ foo -o bar ]is not well defined, use[ foo ] || [ bar ]instead.