actually I have these lines (exemplary) in my .zshrc file:

. ${TOOLS_HOME}/cli/.cli_base
. ${TOOLS_HOME}/cli/.cli_functions
. ${TOOLS_HOME}/cli/.cli_symlinks

This works fine so far. My only problem is, that in these .cli_xxx files I don't have syntax highlighting (For aliases this is ok - but for functions this is very hard).
So I tried this one:

. ${TOOLS_HOME}/cli/cli_base.sh
. ${TOOLS_HOME}/cli/cli_functions.sh
. ${TOOLS_HOME}/cli/cli_symlinks.sh

But (as I red over google) the . is like source and when I source my .zshrc file and execute an alias I sometimes get this error message:

bash:30: maximum nested function level reached

Thats because of the "multi source"??
Somebody have like a "best practice" for storing and versioning aliases/functions/symlinks or do I have to stay with my .cli_xxxx files??

  • 2
    If the only issue is syntax highlighting, then this should not affect what you call your files. Instead, figure out how you can signal to your editor what syntax highlighting it should use from within the file itself. What editor are you using?
    – Kusalananda
    Dec 18 '18 at 10:15
  • actually mostly I use atom - so you say this is the right way what I am doing (with dotfiles)?
    – m1well
    Dec 18 '18 at 10:16
  • 3
    Well, you say that you have something that works. Why break it for the sake of syntax highlighting? Unfortunately I've never used Atom, so I can't really say whether it support modelines, but that's what this feature is usually called. A quick search gave me atom.io/packages/modeline
    – Kusalananda
    Dec 18 '18 at 10:21

I suspect, that the issue is completely unrelated to the name of the files would also happen if you sourced .zshrc in the original state.

Cause of the error

This error usually happens when you call a function from within itself, leading to a recursion. This may inadvertently happen, when you give functions the same name as an external command or builtin that is used within that function. For example:

echo () {
    echo "Out: " $@

The command echo will work just fine, before you define this function, but after the definition it will fail with this error:

% echo foobar
echo:1: maximum nested function level reached; increase FUNCNEST?

(The difference in the message text is probably due to the zsh versions used, which in my case is 5.6.2)

It can also happen through multiple functions calling each other:

foo () {
    echo $@

echo () {
    foo $@

The error message will show the name of the function that cannot be called anymore due to the nesting limit being reached and the line of the function where this call happens. So in the above case either:

% echo foobar
echo:1: maximum nested function level reached; increase FUNCNEST?


% echo foobar
foo:2: maximum nested function level reached; increase FUNCNEST?

In the case of the question it seems that a function with the name bash is called in line 30 of some function.

Fixing it

Unless the recursion is intentional, this can be prevented by telling zsh which non-function command you want to use.

  • If you want the built-in command, just prepend builtin:

    echo ()
        builtin echo "Out: " $@
  • If you want an external command, either prepend command:

    echo ()
        command echo "Out: " $@

    or use its full path

    echo ()
        /bin/echo "Out: " $@

If you are not sure where you are using bash in your zsh configuration, you can use grep to search ${TOOLS_HOME}/cli/ recursively:

grep -r bash ${TOOLS_HOME}/cli/

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.