improve robustness of wordexp and fix handling of 0-word case