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.

Just switched from tcsh to bash 4.2 on OSX, and autocd was what allowed me to do it. But it seems that by default if you type the name of a directory that also happens to be the name of an executable in my path, autocd is not invoked and the command is run.

Is there a way to change this behavior, so that it assumes I want to be safe and cd into the directory specified?

share|improve this question
1  
How about getting into the habit of always typing a slash at the end when you mean a directory? /tmp/ is still two characters shorter than cd /tmp, and it's unambiguous. –  Mikel Mar 11 at 22:03
    
@Mikel this is basically what I have been doing ;) –  Brian Mar 13 at 0:05

1 Answer 1

up vote 4 down vote accepted

You probably can't, which points to an underlying problem concerning why a feature such as autocd can never become standard: it introduces ambiguity. If you switched the behavior: how would you launch a program that is named the same as a currently available subdirectory? It becomes non-deterministic, which is the worst thing a UI can become, imho (and even worse for non-interactive shells, but that is avoidable by simply only setting autocd for interactive shells).

When I say "you probably can't", I mean that I looked through the shopt section of man bash and did not find any such modifier. One can of course fix it by e.g. modifying Bash's source, but I guess your question concerned an available setting to fix this for you.

share|improve this answer
    
good point about how would you ever run a command named the same as a directory if this was in fact possible, definitely not ideal for non-interactive shells. I don't recall the syntax offhand, but I assume it would be similar to how you bypass any aliases you've created to protect yourself from rm -rf * and the like. –  Brian Mar 13 at 0:09

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.