Frequently, when switching my user by root with
su -
, I get strange bash
error messages in the rxvt
console, or even in a TTY. They happen even after a complety system upgrade from scratch, so it is probably a thing in root
HOME.
For example, these:
sh: error importing function definition for `_file'
sh: _file: line 3: syntax error near unexpected token `('
sh: _file: line 3: ` --help | --version | --separator | -!(-*)[vF])'
When I logout, I then get several errors like:
/bin/bash: _sudo: line 19: syntax error near unexpected token `('
/bin/bash: _sudo: line 19: ` --user | --other-user | -!(-*)[uU])'
/bin/bash: error importing function definition for `_sudo'
Even if I do sh
in the console I get
/bin/bash: _file: line 3: syntax error near unexpected token `('
/bin/bash: _file: line 3: ` --help | --version | --separator | -!(-*)[vF])'
/bin/bash: error importing function definition for `_file'
I then logout and login again, and the normal behavior is restored. Until it begins behaving strangely...
I thought it was a problem with '~/.bashrc' or the like, but those files are shared with my normal user that never ever shows errors in console.
There is obviously a bash
script with errors, but I don't know even where to begin looking. What is _sudo
?? The commands grep _sudo $(find . -type f)
and find . -name _sudo
show nothing...
**EDIT**
This is the content of my file /usr/share/bash-completion/completions/sudo
:
# bash completion for sudo(8) -*- shell-script -*-
_sudo()
{
local cur prev words cword split
_init_completion -s || return
local i mode=normal
[[ $1 == *sudoedit ]] && mode=edit
[[ $mode == normal ]] &&
for ((i = 1; i <= cword; i++)); do
if [[ ${words[i]} != -* ]]; then
local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
local root_command=${words[i]}
_command_offset $i
return
fi
if [[ ${words[i]} == -@(!(-*)e*|-edit) ]]; then
mode=edit
break
fi
[[ ${words[i]} == \
-@(user|other-user|group|close-from|prompt|!(-*)[uUgCp]) ]] &&
((i++))
done
case "$prev" in
--user | --other-user | -!(-*)[uU])
COMPREPLY=($(compgen -u -- "$cur"))
return
;;
--group | -!(-*)g)
COMPREPLY=($(compgen -g -- "$cur"))
return
;;
--close-from | --prompt | -!(-*)[Cp])
return
;;
esac
$split && return
if [[ $cur == -* ]]; then
local opts=$(_parse_help "$1")
COMPREPLY=($(compgen -W '${opts:-$(_parse_usage "$1")}' -- "$cur"))
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
if [[ $mode == edit ]]; then
_filedir
fi
} &&
complete -F _sudo sudo sudoedit
# ex: filetype=sh
Asked by Luis A. Florit
(509 rep)
Jul 25, 2024, 02:54 PM
Last activity: Aug 26, 2024, 06:31 PM
Last activity: Aug 26, 2024, 06:31 PM