It seems that if I remove the "-o filenames" from the compspec for cd, I get the correct behavior when it comes to environment variables as arguments to cd.
vnix$ complete -p cd
complete -o filenames -o nospace -F _cd cd
vnix$ cd $HOM<TAB>
vnix$ cd \$HOME
bash: cd: $HOME: No such file or directory
vnix$ complete -o nospace -F _cd cd
vnix$ cd $HOM<TAB>
vnix$ cd $HOME
vnix$
See also bug 177243, although its author seems to be insisting that it's not a duplicate of this one.
It seems that if I remove the "-o filenames" from the compspec for cd, I get the correct behavior when it comes to environment variables as arguments to cd.
vnix$ complete -p cd
complete -o filenames -o nospace -F _cd cd
vnix$ cd $HOM<TAB>
vnix$ cd \$HOME
bash: cd: $HOME: No such file or directory
vnix$ complete -o nospace -F _cd cd
vnix$ cd $HOM<TAB>
vnix$ cd $HOME
vnix$
See also bug 177243, although its author seems to be insisting that it's not a duplicate of this one.