diff options
| author | xq114 <[email protected]> | 2023-05-10 00:01:33 +0800 |
|---|---|---|
| committer | xq114 <[email protected]> | 2023-05-10 00:01:33 +0800 |
| commit | 8ecdc87d0ed33c96caeeeb973702a56a1f8f4c2a (patch) | |
| tree | 92c5b939a18056c733ef76ed4433af45a0000023 /xmake/scripts/virtualenvs/register-virtualenvs.sh | |
| parent | 5b258b7996411c674d255ee15194d0c78afee9de (diff) | |
use pushd and popd to tackle venv
Diffstat (limited to 'xmake/scripts/virtualenvs/register-virtualenvs.sh')
| -rw-r--r-- | xmake/scripts/virtualenvs/register-virtualenvs.sh | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/xmake/scripts/virtualenvs/register-virtualenvs.sh b/xmake/scripts/virtualenvs/register-virtualenvs.sh index 15ed63bcd..1f389b99e 100644 --- a/xmake/scripts/virtualenvs/register-virtualenvs.sh +++ b/xmake/scripts/virtualenvs/register-virtualenvs.sh @@ -21,6 +21,7 @@ if test "${XMAKE_ROOTDIR}"; then export XMAKE_EXE=${XMAKE_ROOTDIR}/xmake else + local -i XMAKE_ROOTDIR=~/.local/bin export XMAKE_EXE=xmake fi @@ -69,22 +70,20 @@ function xrepo { unset XMAKE_PROMPT_BACKUP unset XMAKE_ENV_BACKUP fi - local currentTest="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env)" || return 1 - if [ ! -z "$currentTest" ]; then - echo "error: corrupt xmake.lua detected in the current directory!" - return 1 - fi - "$XMAKE_EXE" lua private.xrepo.action.env.info config $bnd || return 1 - local prompt="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info prompt $bnd)" || return 1 + pushd ${XMAKE_ROOTDIR} 1>/dev/null + "$XMAKE_EXE" lua private.xrepo.action.env.info config $bnd || (popd 1>/dev/null && return 1) + local prompt="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info prompt $bnd)" || (popd 1>/dev/null && return 1) if [ -z "${prompt+x}" ]; then + popd 1>/dev/null echo "error: invalid environment!" return 1 fi - local activateCommand="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info script.bash $bnd)" || return 1 + local activateCommand="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info script.bash $bnd)" || (popd 1>/dev/null && return 1) export XMAKE_ENV_BACKUP="$("$XMAKE_EXE" lua private.xrepo.action.env.info envfile $bnd)" export XMAKE_PROMPT_BACKUP="${PS1}" "$XMAKE_EXE" lua --quiet private.xrepo.action.env.info backup.bash $bnd 1>"$XMAKE_ENV_BACKUP" eval "$activateCommand" + popd 1>/dev/null PS1="${prompt} $PS1" else "$XMAKE_EXE" lua private.xrepo "$@" |
