I am working on some installation of the MPC library and I came accross this command line (called "the initial command" afterwards) :
LD_LIBRARY_PATH=/usr/local/gnu/gmp-6.0.0/lib:/usr/local/gnu/mpfr-3.1.2/lib ../configure --prefix=/usr/local/gnu/mpc-1.0.3 --with-gmp=/usr/local/gnu/gmp-6.0.0 --with-mpfr=/usr/local/gnu/mpfr-3.1.2
where LD_LIBRARY_PATH
is set and where the configure command
../configure --prefix=/usr/local/gnu/mpc-1.0.3 --with-gmp=/usr/local/gnu/gmp-6.0.0 --with-mpfr=/usr/local/gnu/mpfr-3.1.2
is executed after. Note that after the initial line, there is another line of the same type, with another setting of LD_LIBRARY_PATH
and another command.
As I understand it, the initial line is equivalent to
export LD_LIBRARY_PATH=/usr/local/gnu/gmp-6.0.0/lib:/usr/local/gnu/mpfr-3.1.2/lib
../configure --prefix=/usr/local/gnu/mpc-1.0.3 --with-gmp=/usr/local/gnu/gmp-6.0.0 --with-mpfr=/usr/local/gnu/mpfr-3.1.2
unset LD_LIBRARY_PATH
Am I wrong ? If so, if I want to put the initial command in a .sh file, I only have to replace it by the three previous lines, right ? If not, how could I do it ?
a=hello; a=goodbye printenv a; echo "$a"
. Now, in a script, the modifications made to a variable are not seen by the parent shell, so you don't really care about theunset
part anyway (provided your script only does that, and that it is executed and not sourced).unset LD_LIBRARY_PATH
, I could do it and setLD_LIBRARY_PATH
right after to its previous value, value that I would have stored before having modified it. Is there an elegant way of doing this ? What do you mean by "executed and not sourced" ? (I am really interested in the script strict equivalent of the initial command line.)( export LD_LIBRARY_PATH=...; ./configure ...)
. 3. Otherwise it's tricky to save the value of the variable and restore it: you also have to save whether it was set or not…foo=/usr/bin perl -le 'print $ENV{"foo"}'
instead.