Remember 4DOS? They had this great feature: if you typed a directory all by itself on a command line, it would jump to that directory. It saved you typing all that cd nonsense. When you think about it, this makes sense as there is never (at least that I can think of) any other case where just typing a directory does anything else. I mean, why type...

[user@server somedir]$ cd /etc/rc.d/rc0.d/

...when you could type...

[user@server somedir]$ /etc/rc.d/rc0.d/

It always surprised me that no one implemented this in bash, and finally I got around to doing it myself. It's a very simply change to only one file.

See below for a patch against 2.05b as well as a binary I compiled on a fairly old system (so that you won't have clib problems).

If you want to use my binary, just copy it somewhere on your system. Then run it. If it launches ok, you should be good to go.

Note: this new feature does not work in scripts as I enable it only in interactive mode. This is because it is possible that a really lame script would do something like enter the directory by itself and then look for an error code as a way to detect whether a directory is present or not.

And so although it should be safe it's probably safest to leave /bin/bash in place, install it as /bin/bash_patched, and then change it to be your default shell in /etc/passwd.

(to make a patch, do diff -Naur  old_file new_file > patch_file

-- MattWalsh - 09 Mar 2004

Topic attachments
I Attachment Action Size Date Who Comment
Unknown file formatEXT bash manage 1934.2 K 09 Mar 2004 - 23:32 MattWalsh Compiled version of bash with the patch
Unknown file formatpatch bash_dirchange.patch manage 2.3 K 09 Mar 2004 - 23:56 MattWalsh patch agains 2.05b
C source code filec execute_cmd.c manage 101.2 K 10 Mar 2004 - 00:31 MattWalsh The modified source file
Topic revision: r2 - 08 Jan 2007 - MattWalsh
 
This site is powered by the TWiki collaboration platformCopyright © 2008-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback