[clue-tech] Questions about $CDPATH

Mike Bean beandaemon at gmail.com
Sun Feb 6 12:08:55 MST 2011


Right on the money!  Thank you!

Bean

On Sun, 2011-02-06 at 11:43 -0700, David L. Anselmi wrote:
> Mike Bean wrote:
> > mbean at fozzie:~/Dropbox/Documents$ echo $CDPATH
> > :/home/mbean:/home/mbean/Dropbox:/home/mbean/Documents:/home/mbean/Dropbox/bin/dotfiles:/home/mbean/Dropbox/bin/scripts
> 
> I think you're confused about what a search path is.  It's a list of places the cd command will look 
> for a directory that matches what you specify.
> 
> So the ones that work appear in directories in CDPATH.  The ones that don't are not in those 
> directories.  For example, if CDPATH is /home/mbean then cd mbean won't go to /home/mbean but will 
> go to /home/mbean/mbean.
> 
> > Here's the results of testing:
> > mbean at fozzie:~/Dropbox/Documents$ cd mbean
> 
> This is silly because "cd" is a shorter way to get to $HOME.
> 
> > mbean at fozzie:~/Music$ cd Documents
> > /home/mbean/Documents
> > mbean at fozzie:~/Music$ cd Dropbox
> > /home/mbean/Dropbox
> 
> ~mbean is in CDPATH so both of these work.
> 
> > mbean at fozzie:~/Music$ cd dotfiles
> > bash: cd: dotfiles: No such file or directory
> > mbean at fozzie:~/Music$ cd scripts
> > bash: cd: scripts: No such file or directory
> 
> Even though CDPATH contains ~mbean/Dropbox/bin/{dotfiles,scripts} these fail.  Change CDPATH to 
> contain ~mbean/Dropbox/bin and both of these will work.
> 
> So if you want to use CDPATH you have to think about what's in it and arrange your directories 
> accordingly.
> 
> This is congruent with how PATH works.  You include /bin and /bin/ls is found in it.  You don't 
> include /bin/ls in PATH (which is obvious since PATH contains directories but is searched for files, 
> rather than containing directories that are searched for directories).
> 
> Happy Debian Squeeze!
> Dave
> _______________________________________________
> clue-tech mailing list
> clue-tech at cluedenver.org
> http://cluedenver.org/mailman/listinfo/clue-tech




More information about the clue-tech mailing list