.bashrc questions

Are there any advantages of doing one over the other in your .bashrc? They both seem to do the same thing.

HISTFILESIZE=10000 
HISTSIZE=10000
export HISTFILESIZE=10000 
export HISTSIZE=10000

The export command is used to export a variable or function to the environment of all the child processes running in the current shell.

That's the main difference.

Both sets of commands define two variables that are available to everything running in the current shell execution environment.

The second set of commands (using export ) also causes those two variables to be available to everything running in subshells and other execution environments initiated by the current shell execution environment after those variables are exported. Those variables will not be available to processes that were already running at the time those variables were exported no matter how those processes were initiated.

Further to Neo's and Don Cragun's comments, the variables used in your example are shell-specific variables and therefore do not need to be exported.

Andrew

1 Like

Because they are only for bash, not for other programs, I would not export them.
Then they must be redefined with every start of an interactive bash - that means .bashrc is the correct location.

1 Like