title: How to source the setvars.sh file of oneapi inside a sh file
body: <p>I'm working on installzation of oneapi in my pc with CentOS 7 system. After installed the components of oneapi, I want to setup the environment of oneapi by sourcing (in the terminal) the setvars.sh file</p>
  <pre><code>source /opt/intel/oneapi/setvars.sh intel64
  </code></pre>
  <p>the terminal echoes multiple lines of output as it should</p>
  <pre><code>:: initializing oneAPI environment ...
     BASH version = 4.2.46(2)-release
  :: dev-utilities -- latest
  :: tbb -- latest
  :: compiler -- latest
  :: dpl -- latest
  :: mkl -- latest
  :: vtune -- latest
  :: dpcpp-ct -- latest
  :: mpi -- latest
  :: clck -- latest
  :: inspector -- latest
  :: itac -- latest
  :: oneAPI environment initialized ::
  </code></pre>
  <p>then I can find the location of the compilers like ifort through</p>
  <pre><code>which ifort
  </code></pre>
  <p>then it gives</p>
  <pre><code>/opt/intel/oneapi/compiler/2021.1-beta10/linux/bin/intel64/ifort
  </code></pre>
  <p><strong>Here is my question</strong>,</p>
  <p>instead of sourcing setvars.sh directly in the terminal, if I use a sh file like</p>
  <pre><code>#!/bin/bash
  source /opt/intel/oneapi/setvars.sh intel64
  </code></pre>
  <p>and run the sh file with</p>
  <pre><code>bash hello_world.sh
  </code></pre>
  <p>then the outputs still arise as above which I believe can demonstrate that the source command in the sh file had been successfully executed. However, , this time, the environment variables are not probably setted, as <code>which ifort</code> command gives</p>
  <pre><code>/usr/bin/which: no ifort in (/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/wuchen/.local/bin:/home/wuchen/bin)
  </code></pre>
  <p>I noticed this post <a href="https://stackoverflow.com/questions/5725296/difference-between-sh-and-bash">Difference between sh and bash</a>
  and changed the command in the sh file to</p>
  <pre><code>. /opt/intel/oneapi/setvars.sh intel64
  </code></pre>
  <p>But still it doesn't work. I wonder if my problem is due to the setvars.sh itself.</p>