I assume your shell is Bash. I can replicate your problem by redefining eval
like this:
eval() { echo "$1"; }
or similarly. Completion functions use eval
. They expect eval
to be eval
the shell builtin. If eval
is tampered with then they may misbehave.
My tests indicate that eval
being an alias or an executable does not break completions, so it's most likely a function in your case.
Invoke
type eval
Normally the output should be eval is a shell builtin
. If you get eval is a function
then invoke
unset -f eval
and check if completions behave better (or at least differently).
You should investigate where the function comes from. A manual method is to check the startup files (~/.bashrc
and such) and everything they source. There are better methods. Proceed like this:
shopt -s extdebug # enable extra debugging info
declare -F eval
This will tell you the line number and the source file. (Finally run shopt -u extdebug
to disable debugging.)
The above method should be enough to locate the definition of the function. Just in case, few other methods are here: How to find the file where a bash function is defined.
After you find the definition of this eval
function, get rid of it and let eval
be the builtin. Notes:
- Deleting the definition will not automatically fix already running shells. Spawn a new shell; log out and log in; when in doubt, reboot.
- Deleting the definition will break anything that actually needs the function, so further investigation may be required: for what reason was the function there? Consider renaming instead of deleting (at least initially, temporarily), in case the code in the definition is not expendable.
- The function may be defined more than once (and the most recently sourced definition wins). If deleting the definition does not bring the builtin back, there's probably a definition left. Repeat the method.
If completions are not fully fixed, examine the output of declare -F
and check for other functions that replace builtins (use compgen -b
to know what to search for). If needed, analyze them like you just did with eval
and fix similarly.
words=...
) appear there. Maybe you have syntax error somewhere around there. – arensb Apr 07 '21 at 14:18