From man bash
[[ expression ]]
Return a status of 0 or 1 depending on the evaluation of the conditional
expression expression. Expressions are composed of the primaries
described below under CONDITIONAL EXPRESSIONS. Word splitting and pathname
expansion are not performed on the words between the [[ and ]]; tilde
expansion, parameter and variable expansion, arithmetic expansion, command
substitution, process substitution, and quote removal are performed.
Conditional operators such as -f must be unquoted to be recognized as primaries.
Or in short, the pattern is not expanded.
A simple alternative could look like
if [[ $(echo $d/lib*) != "$d/lib*" ]]; then
mv /etc/launchd.conf $d/launchd.conf
fi
Short explanation on how this works:
echo $d/lib*
expands to a list of library files if any are present, this list is not equal to $d/lib*
(which doesn't get expanded) so the mv
is executed
- OTOH if no library files are present, the echo returns the string
$d/lib*
, the !=
evaluates to false and the mv
is not executed