Created
          February 7, 2018 09:33 
        
      - 
      
- 
        Save jlejeune/cb5d3d484ff40967bda76e8eebc64dfd to your computer and use it in GitHub Desktop. 
    Sourcing a shell script
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from subprocess import Popen, PIPE | |
| from os import environ | |
| def source(script, update=1): | |
| pipe = Popen(". %s; env" % script, stdout=PIPE, shell=True) | |
| data = pipe.communicate()[0] | |
| env = dict((line.split("=", 1) for line in data.splitlines())) | |
| if update: | |
| environ.update(env) | |
| return env | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment