Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
bash$ compgen -d -- '~'

Produces empty output.

bash$ compgen -d -- '~mi'

Also produces empty output.

bash$ compgen -d -- '~mice/'
~mice/.pulse
~mice/.mozilla
~mice/Pictures

Is OK.

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

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

1 Answer 1

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

bash$ compgen -u -- '~mi'
~mice

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

 
discard

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.