0

I just discovered that in bash,[[ -d foo-* ]] returns false ($? set to 1) even if a directory named foo-bar exists while [ -d foo-* ] returns true ($? set to 0)

I have to admit that I was surprised as I expected both versions to return true.

What is the rational behind this differing outcome?

marked as duplicate by Kusalananda bash Feb 16 '18 at 7:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    See also the bash manual about [[ ... ]] where it says "Word splitting and pathname expansion are not performed on the words between the [[ and ]]". – Kusalananda Feb 16 '18 at 7:56
  • I missed that. Thanks for the clarification. – René Nyffenegger Feb 16 '18 at 9:51

Browse other questions tagged or ask your own question.