Every time I open terminal 'bash: 0: command not found' is displayed twice

Everytime i open a terminal i get the mentioned error.
I traced to to this line in my .bashrc (the default .bashrc file)

[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion

sure enough, when i execute that file, i get two instances of the error.

bash: 0: command not found
bash: 0: command not found

is this a known issue? my bash completion seems to work fine, so i don’t think this is a huge error.

Remove that and replace it with:

# enable bash completion in interactive shells
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion.d/bash_completion.bash ]; then
    . /usr/share/bash-completion/bash_completion.bash
  elif [ -f /etc/bash_completion.d ]; then
    . /etc/bash_completion.d
  fi
fi

interesting, now when i do
source .bashrc
i get no error, yay!
however, upon opening new terminals i still get the bash: 0: command not found x2

Apparently you have a typo somewhere in your .bashrc. Possibly an extra space before a 0? Possibly twice? Or something isn’t quoted or escaped properly.

More likely:

but they aren’t “my” files, they are the ones already on the system by default… i have no idea what to edit, the bash_completion is really long.

and the issue is in the bash_completion file, that is the one that spits the error.

e.g.

$ . /usr/share/bash-completion/bash_completion 
bash: 0: command not found
bash: 0: command not found

They are now since it’s in your ~/ folder and you did just edit it. :wink:

This is the original that was copied there:
https://gitlab.manjaro.org/packages/core/bash/-/raw/master/dot.bashrc

If there’s a problem with our default Bash settings, we’d like to fix it.

❯ bash
$ . /usr/share/bash-completion/bash_completion 
$ 

:man_shrugging:

lol, touche.

i thought that’s what i was doing here, but im confused now!

where is the original bash_completion file?

That belongs to the bash-completion package which is imported from the Arch extra repo and is not modified in any way. I don’t think there’s anything wrong with it.

Do you use Timeshift? I have snapshots of .bashrc and .zshrc going back a few months… just saying :wink:

If you ever have a problem with .bashrc, browse your timeshift/snapshot folder and look for an older version and use something to compare them (I use meld).

What happens if you do mv .bashrc bashrc.BAD and then quit and open a new terminal?

thanks, good suggestion.

this happened out of the box, i installed manjaro yesterday morning.

ok, i believe i tracked down the source of the issue.

this file, /etc/bash.bashrc has the same ‘erroneous’ line as the default .bashrc file. (i.e. [ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion

I replaced that line with this (as per @Yochanan suggestion above):

# enable bash completion in interactive shells
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion.d/bash_completion.bash ]; then
    . /usr/share/bash-completion/bash_completion.bash
  elif [ -f /etc/bash_completion.d ]; then
    . /etc/bash_completion.d
  fi
fi

I no longer receive bash: 0: command not found when opening terminals anymore.

Not sure if this issue is entirely resolved, as bash_completion still results in errors. but it seems that file does not get used anymore with the code snippets applied.