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?

3

1 Answer 1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .