title: How to export bash variable from function execed in prompt to parent shell?
body: <p>Oh... Probably title is not really easy to interpret. So let's describe it a little bit:</p>
  
  <p>In <code>.bashrc</code> file I set <code>PS1</code> to get custom prompt. In this prompt I need to have some additional info, which I get from other specific function. This function takes some time to exec so it is not cool to wait 1 sec after push enter in console. But I have idea to cached returned value from this specific function. </p>
  
  <p>I need to check cache flag in every prompt print so I cant use variable, I must use function in printing prompt, because sourceing <code>.bashrc</code> is only one times, but if I pass function to <code>PS1</code> it will be execed every time.</p>
  
  <pre>prompt_fun(){
  
      export CACHE_YES=1
      export PROMPT_CACHE="Something"
      echo "$PROMPT_CACHE"    
  
          #in real case here will be checking if cache is turned on. 
          #If yes, we use cached value from exported variable in first time.
          #If no, we exec specific function and export values to env variables.
  }
  
  PS1="$(prompt_fun): "`
  </pre>
  
  <p>Of course, variable <code>CACHE_YES</code> and <code>PROMPT_CACHE</code> are not set in console, so I am unable to control caching be changing <code>CACHE_YES</code>. I know when cache should change so I can type in console to change <code>CACHE_YES=0</code> but my script don't rechange it to <code>CACHE_YES=1</code> after cache new values. </p>
  
  <p>How to make that <code>export</code> in <code>prompt_fun</code> have global effect?</p>