What is causing all these "declare -x …" lines when I open a terminal?

Run

env - HOME="$HOME" /bin/bash --login -xv 2>&1 | tee foo

to startup bash in verbose mode. This will print every line of initialization file as it is read, and every line of initialization file as it is executed, copying the output to a file called foo. Then you can look in foo to see what’s causing declare -x to be called.


Figured out that lots of declare ... statements is the result of having export being run somewhere without an argument.

I found an accidental newline in my .bashrc:

export
VARIABLE=value

Which should have been

export VARIABLE=value

Yes, it is likely that it is coming from your .bashrc because you edited it. You may have introduced a syntax error in the script which could cause that to be output.

You can make sure that these lines exist in your .bashrc by typing:

grep declare ~/.bashrc

You should see at least those 4 lines printed out to the console. You can also try running your .bashrc script from the prompt and seeing if any errors are output:

bash ~/.bashrc