check results before continue

Check if glob() returns some matches before continue, this should fix issue #1690