fix: fail on a nonzero uv installer exit; POSIX quoting for the sg handoff

The Windows installer only checked that uv.exe exists after running the uv
installer, so a failed install that left an older uv.exe behind was accepted;
it now fails on a nonzero exit code.

sg runs its command with /bin/sh, which need not be bash, so the handoff
after installing Docker quotes each argument as POSIX single quotes instead
of with bash's printf %q.
This commit is contained in:
Alex committed 2026-09-16 01:10:11 +01:00
1 parent 7e80f7a091
commit d993aaced0
2 files changed
+15 -2

No files matched your search

+4
View File
@@ -64,6 +64,10 @@ function Install-DocsGPT {
}
$shell = (Get-Process -Id $PID).Path
& $shell -NoProfile -ExecutionPolicy Bypass -File $installer
if ($LASTEXITCODE -ne 0) {
# Without this, a uv.exe left behind by an older install would be accepted below.
throw "The uv installer exited with code $LASTEXITCODE."
}
} finally {
Remove-Item $installer -Force -ErrorAction SilentlyContinue
}
+11 -2
View File
@@ -50,6 +50,14 @@ main() {
die "curl or wget is needed to download $1"
fi
}
# POSIX single-quote encoding: what needs quoting is decided here, not by the shell that runs it.
shell_quote() {
local arg out=""
for arg in "$@"; do
out="$out'$(printf '%s' "$arg" | sed "s/'/'\\\\''/g")' "
done
printf '%s' "$out"
}
sha256_of() {
if has shasum; then
shasum -a 256 "$1" | awk '{print $1}'
@@ -182,9 +190,10 @@ main() {
if [ "$docker_group_pending" = 1 ]; then
if has sg; then
# The docker group applies to new logins; sg gives it to this command now.
# The docker group applies to new logins; sg gives it to this command now. sg runs the
# command with /bin/sh, which need not be bash, so quote for POSIX sh rather than with %q.
local command
command="$(printf '%q ' "$docsgpt" up "$@")"
command="$(shell_quote "$docsgpt" up "$@")"
if have_tty; then
exec sg docker -c "$command </dev/tty"
fi