Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress syntax error or warning in bash_completion every time new terminal is opened?

I enabled bash_completion in my .bashrc file. Now every time I start a terminal, it shows me this warning:

bash: [: too many arguments
bash: [: =: unary operator expected
bash: [: =: unary operator expected
bash: [: too many arguments

For more info, i ran this command:

$ bash .bashrc

And it show me this warning:

/etc/bash_completion.d/gcc: line 50: [: too many arguments
/etc/bash_completion.d/ifupdown: line 3: [: =: unary operator expected
/etc/bash_completion.d/ifupdown: line 19: [: =: unary operator expected
/etc/bash_completion.d/man: line 3: [: too many arguments

Line 50 of /etc/bash_completion.d/gcc:

[ $USERLAND = GNU -o $UNAME = Cygwin ] && \

I don't see what the problem is here? How do I suppress those warnings from coming up a the start of terminal.

EDIT:

I ran bash -xv .bashrc as suggested by Adrian and i found these in the output:

+++ '[' = GNU -o Linux = Cygwin ']'
/etc/bash_completion.d/gcc: line 50: [: too many arguments
.
.
.
+++ '[' = GNU ']'
/etc/bash_completion.d/ifupdown: line 3: [: =: unary operator expected
+++ '[' = GNU ']'
/etc/bash_completion.d/ifupdown: line 19: [: =: unary operator expected

EDIT: 2

Output of bash -x /etc/bash_completion | grep -E 'UNAME|USERLAND'

++ UNAME=Linux
++ UNAME=Linux
++ unset UNAME RELEASE default dirnames filenames have nospace bashdefault plusdirs
like image 740
udiboy1209 Avatar asked Mar 20 '23 17:03

udiboy1209


1 Answers

After troubleshooting this with you I am pretty confident that you have files in /etc/bash_completion.d that belong to an older version of bash-completion and are thus not compatible with the version of /etc/bash_completion you have installed (or vice versa).

I suggest completely uninstalling bash-completion:

$ sudo apt-get purge bash-completion

and verifying that there are no files left afterwards:

$ find /etc/bash_completion*

If there are, delete them manually.

Afterwards re-install bash-completion:

$ sudo apt-get install bash-completion
like image 123
Adrian Frühwirth Avatar answered Apr 08 '23 12:04

Adrian Frühwirth