Surely one space after the "if" and one space after the "[" and one space before the "]".
if [ -f /var/log/messages ]
then
echo "This file exists"
fi
if [ -d /var/log ]
then
echo "This directory exists
fi
if [ ! -d /var/log ]
then
echo "This directory does not exist"
fi
For me - only for ! or negative condition I should have to put space after IF,"[" and "]" but for normal or posivitive condtion only one space after if working. Anyway it good practice to put space as mentioned by you.
It's nonstandard in many ways, the 'read' command doesn't work right in some situations. Besides, it's not a ksh variant. pdksh seems to be a ksh88 variant, but this guy's shell, whatever it is, might be even older yet..!
The [[ builtin is a kornism and bashism with better-defined semantics than [ (a.k.a. test). If you want your script to be portable as in work with all POSIX-conformant shell script interpreters, you should use the more limited [.
As regards dash and POSIX conformance, according to the current manpage for dash:
Unlike a number of other shells, I do not believe that dash has passed the VSC-PCTS2003 POSIX Certification Test Suite.
It is easy to claim POSIX conformance but a testsuite is the only valid indicator of conformance.
In ksh the bracket type is significant and important. It distinguishes between a "Test" and a "Conditional Expression". There is some common syntax but as soon as you get into boolean expressions they are quite different.