Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have just a cosmetic question.

I export some variable at my .bashrc as the following:

export LD_LIBRARY_PATH=/usr/local/matlab/bin/glnxa64:\
$FASTNET_INSTALL_PATH/lib:$EGRINGERANATOOLS/lib:\
$LD_LIBRARY_PATH

but I am used to indent the lines consequent to the start of the command to better viewing, like:

export LD_LIBRARY_PATH=/usr/local/matlab/bin/glnxa64:\
  $FASTNET_INSTALL_PATH/lib:$EGRINGERANATOOLS/lib:\
  $LD_LIBRARY_PATH

But if I do that, I will get an error like this:

-bash: export: `~/fastnet/install/lib:~/Documents/D3PD/EgRingerAnaTools/lib:': not a valid identifier

Is there a way to indent the lines as I want?

Thanks!

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can create a function like this...

setpath() {
    oldIFS=$IFS; IFS=":"
    var=$1; shift; eval "$var=\$*; export $var"
    IFS=$oldIFS; unset oldIFS
}

setpath LD_LIBRARY_PATH \
    /usr/local/matlab/bin/glnxa64  \
    "$FASTNET_INSTALL_PATH/lib"    \
    "$EGRINGERANATOOLS/lib"        \
    "$LD_LIBRARY_PATH"             ;

(I use this function in my ~/.profile, so it was written to be compatible with any shell that reads that file, including sh, ksh, bash, zsh... It would be shorter if written in pure Bash.)

share|improve this answer
    
Now I'm wondering what the hell is egringerana, which Google has exactly zero results for. –  grawity Aug 15 '13 at 23:14
    
Hahhahah, it is a very secret project that I've failed making it secret. Just kidding, it is a project for CERN ATLAS detector for electron and photon identification. EG stands for egamma (electron and photon), RINGER is the project's name, and ANA analysis. If you search for atlas ringer cern you will find something. –  Werner Oct 3 '13 at 3:18
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.