2020-03-24 19:30:54 +00:00
|
|
|
#
|
|
|
|
# This entrypoint is to allow xxh getting current environment variables
|
|
|
|
# and pass some of them to xxh session to seamless transition to host.
|
|
|
|
#
|
2020-03-29 10:33:35 +00:00
|
|
|
# Usage in bash: source xxh.bash [ordinary xxh arguments]
|
2020-03-24 19:30:54 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
local_xxh_home=~/.xxh
|
|
|
|
|
|
|
|
eargs=""
|
|
|
|
|
2020-03-29 10:33:35 +00:00
|
|
|
for pluginenv_file in $local_xxh_home/.xxh/plugins/*-bash-*/env; do
|
2020-03-24 19:30:54 +00:00
|
|
|
if [[ -f $pluginenv_file ]]; then
|
|
|
|
plugin_name=$(basename `dirname $pluginenv_file` | tr a-z A-Z | sed 's/-/_/g')
|
|
|
|
|
|
|
|
if [[ $XXH_VERBOSE == '1' || $XXH_VERBOSE == '2' ]]; then
|
|
|
|
echo Load plugin env $pluginenv_file
|
|
|
|
fi
|
|
|
|
|
|
|
|
for l in `cat $pluginenv_file`
|
|
|
|
do
|
|
|
|
if [[ -v $l ]]; then
|
|
|
|
d=`declare -p $l | base64 --wrap=0`
|
|
|
|
dd="export $plugin_name"_EXE_"$l=$d"
|
|
|
|
ddd=`echo $dd | base64 --wrap=0`
|
|
|
|
if [[ $XXH_VERBOSE == '2' ]]; then
|
|
|
|
echo Prepare plugin env $pluginenv_file: name=$l, declare=$d
|
|
|
|
echo Prepare plugin env $pluginenv_file bash: $dd
|
|
|
|
fi
|
|
|
|
eargs="$eargs +heb $ddd"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2020-03-29 12:43:06 +00:00
|
|
|
|
|
|
|
CDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
2020-03-24 19:30:54 +00:00
|
|
|
[ -f $CDIR/xxh ] && xxh=$CDIR/xxh || xxh='xxh'
|
2020-03-29 12:43:06 +00:00
|
|
|
[ -f $CDIR/../xxh ] && xxh=$CDIR/../xxh || xxh='xxh'
|
2020-04-01 15:11:06 +00:00
|
|
|
$xxh +s xxh-shell-bash-zero $eargs "$@"
|