Use of double square brackets in ksh

Hi

First apologies if this has been raised before.

I've got the following in a ksh script:

if [[ ! -f /etc/ssh/ssh_host_rsa_key -o ! -f /etc/ssh/ssh_host_dsa_key ]]

For some reason this does not work. But if I remove the double square brackets to:

if [ ! -f /etc/ssh/ssh_host_rsa_key -o ! -f /etc/ssh/ssh_host_dsa_key ]

This works.

I thought ksh supported the [[...]]. Or is there more to it?

Thanks in advance.

Read

[
and
[[
are both command but like
cp and mv are different, same situation between [ and [[.
test command (you can write it also [ ) has been already in Bourneshell. Testing command (I mean [[ ) has done later, maybe it was David Korn ?.

Ex. I'm so old sh user, I use always old test command (sometimes I write it using [ ).
I have never need to use [[ ]] testing. If test is not enough, I like more case pattern to use comparing strings. So read manual (bash or ksh) and try to see the light between [ and [[.

More about if and test. ( Nothing about [[ )

To throw my 2 cents in!

I don't like [[ ]] partly for this reason:

if [[ $X -eq 1 ]]; then
  echo X is 1
else
  echo X is not 1
fi

If X is not 1 or X is not set the else part is executed (there's no error).

If X is not set and you use [ ], then...

if [ $X -eq 1 ]; then
  echo X is 1
else
  echo X is not 1
fi
./Test[1]: [: argument expected

I now know that X is not set. If I expect X to be set, then I should expect an error when it's not.

If it's OK for X not to be set, then I'd prefer to use:

if [ "$X" -eq 1 ]; then
  echo X is 1
else
  echo X is not 1
fi

At least then I'm aware of the fact, rather than blindly using [[ ]] which to me suggests that you really have no idea of the state of your variables.

Just my preference!

PS: I'm aware that didn't answer your question, but I think that was answered already...