Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Close two false passes in the uninstaller argument tests, and document the piped help form (#7690)

Daniel Han31a651a40736
diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh
index 29b12dea19a..f759b9cdffb 100755
--- a/scripts/uninstall.sh
+++ b/scripts/uninstall.sh
@@ -17,6 +17,15 @@ Usage:
curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/main/scripts/uninstall.sh | sh
sh scripts/uninstall.sh
+To read this help from the piped form, sh needs -s so the arguments reach the
+script instead of the shell. Spelled out, with the same URL as above:
+ curl -fsSL https://raw.githubusercontent.com/unslothai/unsloth/main/scripts/uninstall.sh | sh -s -- --help
+
+Never pipe to `sh -h` expecting help. Neither form prints this message: where
+-h is accepted (bash, zsh, macOS /bin/sh) it is the shell's own hashall option,
+so the shell consumes it and the script uninstalls with no arguments; where it
+is not (dash, busybox sh) the shell exits with "Illegal option -h".
+
Stops running Unsloth Studio servers, then removes the install dir, launcher
data dir, CLI shim, desktop shortcut, macOS .app bundle and Launch Services
entry. The Hugging Face cache at ~/.cache/huggingface is left in place.
diff --git a/tests/sh/test_uninstall_arg_guard.sh b/tests/sh/test_uninstall_arg_guard.sh
index 068ef88a904..d4c798c8d9d 100755
--- a/tests/sh/test_uninstall_arg_guard.sh
+++ b/tests/sh/test_uninstall_arg_guard.sh
@@ -120,8 +120,19 @@ for _flag in --help -h; do
run_uninstall "$FIXTURE_HOME" "$_flag"
check "$_flag exits 0" "0" "$RC"
assert_says "$_flag prints usage" "Unsloth Studio uninstaller" "$OUT"
+ # Inside the loop: make_home mints a fresh fixture per iteration, so a check
+ # placed after the loop only ever sees the last flag's home and --help could
+ # wipe an install unnoticed.
+ assert_fixture "$_flag keeps the install" "$FIXTURE_HOME" present
done
-assert_fixture "help keeps the install" "$FIXTURE_HOME" present
+
+# The piped help form has to be spelled out, because the obvious one never
+# works: where -h is accepted it is the shell's own hashall option, so
+# `... | sh -h` uninstalls with no arguments; where it is not, the shell exits.
+# Its own run, not the loop's leftover $OUT, so a failure names the right check.
+make_home
+run_uninstall "$FIXTURE_HOME" --help
+assert_says "usage documents the piped help form" "sh -s -- --help" "$OUT"
echo "=== unknown arguments: abort before touching anything ==="
@@ -140,10 +151,14 @@ assert_fixture "a rejected positional argument keeps the install" "$FIXTURE_HOME
make_home
run_uninstall "$FIXTURE_HOME" --dry-run --help
check "'--dry-run --help' exits 2" "2" "$RC"
+# An exit code alone would pass even if the guard rejected the argument only
+# after the removal had already started.
+assert_fixture "'--dry-run --help' keeps the install" "$FIXTURE_HOME" present
make_home
run_uninstall "$FIXTURE_HOME" --help --dry-run
check "'--help --dry-run' exits 0" "0" "$RC"
+assert_fixture "'--help --dry-run' keeps the install" "$FIXTURE_HOME" present
echo "=== no arguments: the guard must not have broken the uninstall ==="
@@ -163,6 +178,18 @@ else
assert_fixture "no arguments removes the install" "$FIXTURE_HOME" gone
fi
+echo "=== behaviour: the documented piped help form reaches the guard ==="
+
+# Portable counterpart to the Linux-only pipe-buffer case below: `sh -s --` is
+# the only piped spelling that gets arguments to the script rather than to the
+# shell, so it is the one the usage text points at and the one that has to work
+# everywhere.
+make_home
+OUT=$(HOME="$FIXTURE_HOME" sh -s -- --help < "$UNINSTALL_SH" 2>&1) || true
+assert_says "'sh -s -- --help' prints usage" "Unsloth Studio uninstaller" "$OUT"
+assert_not_says "'sh -s -- --help' never starts the uninstall" "$BODY_MARKER" "$OUT"
+assert_fixture "'sh -s -- --help' keeps the install" "$FIXTURE_HOME" present
+
echo "=== behaviour: a piped --help must not break the writer ==="
# Shrink the pipe so an unread script tail produces a broken writer.