Skip to content

[Solved][Linux] /bin/bash: warning: shell level (1000) too high, resetting to 1

Problem

/bin/bash: warning: shell level (1000) too high, resetting to 1

This error I was encountered when I writing the automation script.

I just want to call a command where is /usr/bin/x, but I put another x command at ~/bin/ to call /usr/bin/x.

The local directory priority is higher than /usr/bin/, so my x command is call itself… that cause the infinite loop.

It is really interesting.

Simply put, it accumulate the shell level, to reach the threshold (default is 1000) and trigger the warning message.


Solution

There are two solutions: one is that this is really an error in calling the script itself. At this time, we should change the method of calling ourselves, for example, by changing the name, etc.

You can also check ~/.bashrc or ~/.bash_profile and other configuration files to confirm that there are no command conflicts.

But another situation is that we really need to call ourselves recursively, how to hide the warning?

In fact, the best solution is still to use loops in scripts, which not only does not trigger warnings, but is also easier to understand and control.


References


Read More

Tags:

Leave a Reply