KHTDR - cd is redundant

Tell me, if I type the name of a directory at the command line, what should happen?

What actually happens?

If I type ~, ./name, or name/, then bash recognizes the explicit reference to a directory, and confirms that, yes, that is a directory. Thanks bash.

If I type something that happens to be a directory, but is not explicit (ex: .ssh with no trailing slash), then bash tells me it cannot find that command.

What about other files? What if I type the name of a file instead of a directory?

Like directories, it depends what you type. If I'm in my home directory and I type .bashrc, it tells me that it cannot find that command. Much like when I typed an implicit directory name. It tried and failed to run a command.

But what if I'm more explicit and type ./.bashrc? Then bash displays the error, 'Permission denied'.

That's not the same behavior as with directories. It should have said that the file exists. Like it said the directory exists.

But of course, we know better. A file can be exectuable, and when I type the name of it, it will be executed. If it is not executable, then I don't have permission to execute it.

So files and directories are both executable. Well, directories are 'searchable'. But the bit that sets this flag is the same: x.

If a file has the executable bit set, it is considered executable and can be run by typing the name.

If a directory has the exectuable bit set, then it is considered searchable and typing its name confirms its existence.

Wait... the existence is confirmed, but the return status code is 126, clearly indicating a failure of some kind!

Alright, enough of the build up. If I type the name of a directory, take me there please. There is nothing else I could have meant by typing the name of the directory. What else could I possible want than to go home when I type ~.

This is what the fish shell does. I use it wherever I can.

When I find myself using bash, I repeatedly type the destination directory name, only to be frustrated when things aren't doing what I assumed.

riddle for the insomniacs

Is there a way to trap status codes in bash, similar to how we can trap signals? If so, I can't find it. If you know, please tell me.

Where are the comments? There are no comments. Better yet, email me with your suggestions, corrections, additions, questions, whatever. If it adds to the discussion, I will happily include it here with a link to your work.