set MONGODB="/usr/local/mongodb/bin"
This is not a variable assignment. (It is one in C shell (csh, tcsh), but not in Bourne-style shells (sh, ash, bash, ksh, zsh, …).) This is a call to the set
built-in, which sets the positional parameters, i.e. $1
, $2
, etc. Try running this command in a terminal, then echo $1
.
To assign a value to a shell variable, just write
MONGODB="/usr/local/mongodb/bin"
This creates a shell variable (also called a (named) parameter), which you can access with $MONGODB
. The variable remains internal to the shell unless you've exported it with export MONGODB
. If exported, the variable is also visible to all processes started by that shell, through the environment. You can condense the assignment and the export into a single line:
export MONGODB="/usr/local/mongodb/bin"
For what you're doing, there doesn't seem to be a need for MONGODB
outside the script, and PATH
is already exported (once a variable is exported, if you assign a new value, it is reflected in the environment). So you can write:
MONGODB="/usr/local/mongodb/bin"
PATH=${PATH}:${MONGODB}
Grepping around in /etc turned up a link that Googling did not. It turns out you can control this in the file /etc/fstab
. Just add a line that says
none / cygdrive binary 0 0
and the problem should be fixed. No more kludgey fixes in .bashrc, and no messed-up $PATH.
Best Answer
For bash the PATH is set initially in
/etc/profile
By default it includes the Windows PATH
If you need to modify it the best place are
.bash_profile
and.bashrc