1

In zsh, executing the directory path will cd into it. I want to make bash shell to behave the same. The idea is to check and see if the error is bash: /xyz: Is a directory and cd into '/xyz' and silence the error message. For this to work I need a custom error handler. trap catches signals and the mentioned error does not create a signal (or does it?).

This is not about the bash script, but the actual bash shell one uses every day. Is it possible?

1

Totally my bad. trap "errHandler" ERR actually works, a typo kept me looking for solution for two hours. Must look into the plugin oh-my-zsh has activated for me by default, because zsh has no such behavior by default.

And by the way, the easy method is to use autocd added in bash 4.0: https://apple.stackexchange.com/a/55424

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.