On 7/17/13 10:53 AM, Mark W. Johnson wrote:
> Linda,
>
> Don't get hung up on:
>
> function _cd { command cd "$@"; }
> alias cd=_cd
>
> In my real _cd function it saves off the directories visited, but I didn't
> want to complicate the issue, so I replaced my useful _cd function to
> something useless but simpler to demonstrate the problem.
>
> I did just update my version of bash, but unfortunately I'm not sure what
> version I was previously running.
>
> I have one piece of information that I don't understand. If I unalias cd, I
> still have the problem. If however, I never set the alias there's no
> problem. If I set the alias but then unset -f _cd, I get:
>
> cd bash: completion: function `_cd' not found
>
> So it's as if once the alias is set, tab completion always follows the alias
> even after I unset it.
Alias expansion is performed when a function is defined. Let's say you
have the above alias defined before you define your completions. If you
define a shell function to produce the completions for `cd', and that shell
function uses `cd' to do its work, the cd -> _cd alias expansion will
have been performed before the shell function is called.
Enabling -x will allow you to see exactly what happens when you attempt
tab completion.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU [email protected] http://cnswww.cns.cwru.edu/~chet/