3 ms·
(in bash, OSX) if I type $ type cd cd is a function cd () { builtin cd "$@"; local result=$?; __rvm_project_rvmrc; __rv
by scrrr 15y ago
(in bash, OSX) if I type
$ type cd
cd is a function
cd ()
{
builtin cd "$@";
local result=$?;
__rvm_project_rvmrc;
__rvm_after_cd;
return $result
}
I don't really understand what happens, but the "builtin" looks like some sort of "super", e.g. call original cd, which would allow to chain multiple overrides, no?
- pilif 15y agoNo. Builtin does just that. It calls the implementation built into the shell, so that's the original plain cd. If two utilities provide their cd(), the last loaded one wins. builtin cd is always the plain built in one. You would need to check whether cd is already overridden, then rename that cd to something else and call that instead of builtin. If it's at all possible to rename functions in bash (I don't know)