14 lines
325 B
Bash
14 lines
325 B
Bash
import-env() {
|
|
for source_name in $@; do
|
|
SOURCE_PID=$(pgrep $source_name | head -n 1)
|
|
if [[ -n $SOURCE_PID ]]; then break; fi
|
|
done
|
|
if [[ -z $SOURCE_PID ]]; then
|
|
echo "import-env: No matching process for: $*"
|
|
return 1;
|
|
fi
|
|
|
|
SOURCE_ENV=("${(@ps:\000:)$(</proc/${SOURCE_PID}/environ)}")
|
|
export ${SOURCE_ENV[@]:#}
|
|
}
|