How to call an internal function in bash if I defined the same name?

I want to overload functionality cdin bash so that I can perform the following checks:

if the directory is not in DIRSTACK → pushd dir

else cd dir(or cd ~#)

However, now I get a recursive loop when trying cd

The reason for this is that I am trying to get around the fact that bash does not support set dunique

+3
source share
2 answers

Use the builtin builtin function:

cd () {
    builtin cd "$@"
}
+7
source

See also here for various attempts to work around this.

0
source

Source: https://habr.com/ru/post/1742435/


All Articles