开发者

export keyword in BASH scripting

I am trying to install PETSc on my Ubuntu laptop. The first step of the installation is to invoke the following commands in the top level directory of the PETSc directory in the terminal.

export PETSC_DIR=$PWD
./config/configure.py --with-cc=gcc --with-fc=gfortran --download-f-blas-lapack=1 --download-mpich=1
make all tes开发者_StackOverflow社区t

Question 1: Should I actually enter in the word 'PWD' or the address of the top level PETSc directory?

Question 2: What I wanted to understand what the export keyword does in general and in particular what it does in the example. I have looked at some references on the export keyword and all of them did not really explain clearly. Probably I have been looking in the wrong places.

I have never done any shell scripting so a detailed answer would be very helpful...Thank you so much!!


All export does is make the value of an environment variable available to child processes.

In this case, they're assuming that you're in the top level directory of the PETSc directory. So using $PWD (print working directory) is just a shortcut so you don't have to type out the path. The effect should be identical:

[jm72@localhost PETSc_1_1_1_1]$ pwd
/home/jm72/soft/PETSc_1_1_1_1
[jm72@localhost PETSc_1_1_1_1]$ export PETSC_DIR=$PWD
[jm72@localhost PETSc_1_1_1_1]$ echo $PETSC_DIR
/home/jm72/soft/PETSc_1_1_1_1
[jm72@localhost PETSc_1_1_1_1]$ export PETSC_DIR=/home/jm72/soft/PETSC_1_1_1_1
[jm72@localhost PETSc_1_1_1_1]$ echo $PETSC_DIR
/home/jm72/soft/PETSC_1_1_1_1
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜