Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
bash$ compgen -d -- '~'

Produces empty output.

bash$ compgen -d -- '~mi'

Also produces empty output.

bash$ compgen -d -- '~mice/'

Is OK.

bash$ compgen -d -- '~mice/Do'

Also OK.

Is it a bug in compgen that it is produces empty output for '~' and '~mi'? If it is a bug, will it break something when fixed?

share|improve this question

The first two, I suspect, need to be completed as tilde expansions before they can be completed as directory names.

bash$ compgen -u -- '~mi'

You cannot, however, specify both -d and -u in the same call to compgen.

Note the following:

bash$ compgen -d -- '~/'     # Like #1, but with trailing /: it works
bash$ compgen -d -- '~mice'  # Like #3, but w/o trailing /: it doesn't work

So incomplete tilde expansions will not be expanded to the proper directory by -d, and "complete" means including the terminating path separator character.

It might be worth filing a bug report, although I suspect it works as intended. At the very least, you might get a better explanation for the current behavior.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.