When one issues the set
command without arguments at a bash prompt (which should output a list of shell variables and their values), a script of 8,274 lines scrolls by. Examining this script shows that it is instructions to the shell for executing commands – and it seems that it runs python scripts, making it essentially a kludge of monstrous proportions. I've seen other builtins behave in a few ways
No output:
Me:~$ wait
Me:~$ true
Me:~$ test
An error, with no usage hint:
Me:~$ select
bash: syntax error near unexpected token `newline'
An error, with usage hint:
Me:~$ source
bash: source: filename argument required
source: usage: source filename [arguments]
Me:~$ return
bash: return: can only `return' from a function or sourced script
I'm having trouble understanding why set
behaves in this way. It seems undocumented, and I wasn't really expecting it. I'm troubled as to why this happens. Can anyone explain?
Best Answer
Those 8k lines are mainly completion functions from the bash-completion package. On my old desktop, bash uses almost a second to read through and define all those functions, most of which I never use, so I disable it.
To disable it, edit your ~/.bashrc, locate these three lines near the end, and prepend a
#
to each of the lines.Next time you run an interactive bash session,
set
will only output about 50-100 lines; mostly environment variables and special shell variables.