import-env: allow specifying fallback names
This commit is contained in:
		
							parent
							
								
									9b6c44cce0
								
							
						
					
					
						commit
						b9b6e44f98
					
				
					 1 changed files with 5 additions and 2 deletions
				
			
		|  | @ -1,7 +1,10 @@ | ||||||
| import-env() { | import-env() { | ||||||
| 	SOURCE_PROCESS=$1 | 	for source_name in $@; do | ||||||
| 	SOURCE_PID=$(pgrep $SOURCE_PROCESS | head -n 1) | 		SOURCE_PID=$(pgrep $source_name | head -n 1) | ||||||
|  | 		if [[ -n $SOURCE_PID ]]; then break; fi | ||||||
|  | 	done | ||||||
| 	if [[ -z $SOURCE_PID ]]; then return 1; fi | 	if [[ -z $SOURCE_PID ]]; then return 1; fi | ||||||
|  | 
 | ||||||
| 	SOURCE_ENV=("${(@ps:\000:)$(</proc/${SOURCE_PID}/environ)}") | 	SOURCE_ENV=("${(@ps:\000:)$(</proc/${SOURCE_PID}/environ)}") | ||||||
| 	export ${SOURCE_ENV[@]:#} | 	export ${SOURCE_ENV[@]:#} | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 crater2150
						crater2150