(Not) Patching Bash

Volume 6, Issue 89; 29 Sep 2003

I don’t care what anyone says, tab completion of symbolic links to directories should be just like tab completion of actual directories. (Update: Everyone’s entitled go off half-cocked sometimes, right?)

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

Martin Fowler

A few days ago, I wrote:

Some recent incarnation of bash started treating tab completion of symbolic links to directories differently from tab completion of actual directories. Specifically, it stopped adding the trailing “/”.

I remember asking around when I first noticed this behavior some months ago: it’s intentional. I’ve forgetten the explanation, but I remember not being convinced.

If this behavior bothers you, here’s a patch that fixes it. Yes, you have to rebuild from sources, but it’s worth it.

Obviously, I could have used Google to find the reason. Blush! Thanks, Arien.

Jean-Baptiste Quenot went on to point out that my patch is entirely unnecessary. There’s a readline option to restore the “right” behavior:

set mark-symlinked-directories on

Thanks, Jean-Baptiste. I should have known better. My bad.


Guess this was your post: http://lists.debian.org/debian-user/2001/debian-user-200111/msg05061.html

Reasoning: http://mail.gnu.org/archive/html/bug-bash/2003-05/msg00134.html

Found through: http://www.google.com/search?q=bash+symbolic+link+tab+completion

—Posted by Arien on 30 Sep 2003 @ 04:56 UTC #

On Debian, bash installation includes /etc/bash_completion, which you can source in your .bashrc. It will naturally add a trailing slash when completing symlinks to directories, and also provide you with many more completions.

By default, it is not sourced.

—Posted by Jean-Baptiste Quenot on 03 Oct 2003 @ 11:56 UTC #

Ooops, no I was wrong. In fact it is an optional behaviour that can be disabled by adding the following line in your .inputrc:

set mark-symlinked-directories on

Sometimes you want to remove the link itself, without a trailing slash, and sometimes you want to access the target (with trailing slash). That was the intention of the author when performing this change.

—Posted by Jean-Baptiste Quenot on 03 Oct 2003 @ 12:04 UTC #