summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxq114 <[email protected]>2021-08-24 22:21:17 +0800
committerxq114 <[email protected]>2021-08-24 22:21:17 +0800
commitb54b0ba654bb8b230efff2bd709839cf32bfb87e (patch)
tree6e71cff5dcb8156696349dbb30496cea59f013cd
parente273de15d253d4dc1b904e4fa0da5fb1bbe57304 (diff)
make prompt output more robust
-rw-r--r--scripts/register-virtualenvs.sh2
-rwxr-xr-xscripts/xrepo.bat6
-rw-r--r--xmake/modules/private/xrepo/action/env.lua2
-rw-r--r--xmake/scripts/xrepo-hook.psm12
4 files changed, 6 insertions, 6 deletions
diff --git a/scripts/register-virtualenvs.sh b/scripts/register-virtualenvs.sh
index 13a661435..700d8dd99 100644
--- a/scripts/register-virtualenvs.sh
+++ b/scripts/register-virtualenvs.sh
@@ -19,7 +19,7 @@ function xrepo {
unset XMAKE_ENV_BACKUP
fi
"$XMAKE_EXE" lua private.xrepo.action.env.info config || return 1
- local prompt="$("$XMAKE_EXE" lua private.xrepo.action.env.info prompt)" || return 1
+ local prompt="$("$XMAKE_EXE" lua --quiet private.xrepo.action.env.info prompt)" || return 1
if [ -z "${prompt+x}" ]; then
return 1
fi
diff --git a/scripts/xrepo.bat b/scripts/xrepo.bat
index c8714a11c..77acf7d24 100755
--- a/scripts/xrepo.bat
+++ b/scripts/xrepo.bat
@@ -22,7 +22,7 @@
if !errorlevel! neq 0 (
exit /B !errorlevel!
)
- @%XMAKE_EXE% lua private.xrepo.action.env.info prompt 1>nul
+ @%XMAKE_EXE% lua --quiet private.xrepo.action.env.info prompt 1>nul
if !errorlevel! neq 0 (
echo error: xmake.lua not found^^!
exit /B !errorlevel!
@@ -39,13 +39,13 @@
if !errorlevel! neq 0 (
exit /B !errorlevel!
)
- @%XMAKE_EXE% lua private.xrepo.action.env.info prompt 1>nul
+ @%XMAKE_EXE% lua --quiet private.xrepo.action.env.info prompt 1>nul
if !errorlevel! neq 0 (
echo error: xmake.lua not found^^!
exit /B !errorlevel!
)
endlocal
- for /f %%i in ('@%XMAKE_EXE% lua private.xrepo.action.env.info prompt') do @(
+ for /f %%i in ('@%XMAKE_EXE% lua --quiet private.xrepo.action.env.info prompt') do @(
@set "PROMPT=%%i %PROMPT%"
)
@set XMAKE_PROMPT_BACKUP=%PROMPT%
diff --git a/xmake/modules/private/xrepo/action/env.lua b/xmake/modules/private/xrepo/action/env.lua
index 297a0717c..91d9317ed 100644
--- a/xmake/modules/private/xrepo/action/env.lua
+++ b/xmake/modules/private/xrepo/action/env.lua
@@ -317,7 +317,7 @@ end
function info(key)
if key == "prompt" then
assert(os.isfile(os.projectfile()), "xmake.lua not found!")
- print("[%s]", path.filename(os.projectdir()))
+ io.write("[" .. path.filename(os.projectdir()) .. "]")
elseif key == "envfile" then
print(os.tmpfile())
elseif key == "config" then
diff --git a/xmake/scripts/xrepo-hook.psm1 b/xmake/scripts/xrepo-hook.psm1
index 902ef3b16..53342fba0 100644
--- a/xmake/scripts/xrepo-hook.psm1
+++ b/xmake/scripts/xrepo-hook.psm1
@@ -21,7 +21,7 @@ function Enter-XrepoEnvironment {
}
$xmakeColorTermBackup, $Env:XMAKE_COLORTERM = $Env:XMAKE_COLORTERM, "nocolor";
- $xrepoPrompt = (& $Env:XMAKE_EXE lua private.xrepo.action.env.info prompt | Out-String);
+ $xrepoPrompt = (& $Env:XMAKE_EXE lua --quiet private.xrepo.action.env.info prompt | Out-String);
$Env:XMAKE_COLORTERM = $xmakeColorTermBackup;
if (-not $xrepoPrompt.StartsWith("[")) {
Write-Host $xrepoPrompt;