Use wordexp(1) (http://linux.die.net/man/3/wordexp) for this instead.