Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .