unsloth/tests/sh
Daniel Han bc07d3a2df
Installer: wrap install.sh in a function so a piped install cannot report curl (56) (#7548)
* Installer: wrap install.sh in a function so a piped install cannot report curl (56)

`curl -fsSL https://unsloth.ai/install.sh | sh` makes sh the READER of a pipe.
The file is ~150KB, far more than a pipe buffer holds, so a top-level `exit` left
sh dead with thousands of lines unread. The write end then failed and curl
appended

    curl: (56) Failure writing output to destination, passed 16357 returned 0

after the installer's own message, which reads as a download failure rather than
the real diagnosis. 29 of the 35 exits are in the first half of the file, so every
early failure on every platform looked like a bad download.

Measured, piping this file into sh and forcing an early exit:

    before:  writer rc=141 (SIGPIPE)   reader rc=1
    after:   writer rc=0               reader rc=1

Through a real curl against a local server, curl rc went 23 -> 0 while the
installer's own exit code kept propagating.

Defining a function forces sh to parse to the closing brace before running
anything, so the pipe is always drained. install.ps1 has always had this shape
(Install-UnslothStudio invoked at the end of the file); this brings install.sh
into line.

Deliberately not reindented. Shell ignores leading whitespace, so the diff stays
two hunks instead of 4400 reflowed lines, and `exit` still exits the shell from
inside a function, so no control flow changes.

tests/sh/test_install_pipe_safety.sh pins both halves of the contract: the writer
must survive, and the installer's real exit code must still reach the caller. It
fails against the unwrapped file (writer rc=141).

* Tighten the pipe-safety comments

Compress the install.sh wrapper rationale and the test header down to the
parts that are not obvious from the code. Comments only, the parsed command
tree of both files is byte identical.

---------

Co-authored-by: danielhanchen <unslothai@gmail.com>
2026-07-28 21:16:31 -07:00
..
test_apt_distro_prompt.sh install.sh, setup.sh: apply the no-tty consent fix to the remaining sites (#7470) 2026-07-26 05:22:28 -07:00
test_get_torch_index_url.sh Fix ROCm wheel-index unit test: extract the gfx-arch probe helpers get_torch_index_url now calls (#7399) 2026-07-24 02:12:16 -07:00
test_install_host_defaults.sh Windows installer: fix DiskPart UAC mid-install, drive-root cache, and spurious unsloth.exe rename warning (#6296) 2026-06-22 03:09:08 -07:00
test_install_pipe_safety.sh Installer: wrap install.sh in a function so a piped install cannot report curl (56) (#7548) 2026-07-28 21:16:31 -07:00
test_install_rollback_lifecycle.sh Surface actionable installer failures in Studio desktop (#7529) 2026-07-28 10:19:44 +02:00
test_install_uv_override_space.sh Installer: make UV_OVERRIDE space-safe on Apple Silicon (#6503) (#6639) 2026-06-24 17:34:18 -07:00
test_linux_deps_gate.sh Installer: stop requiring a developer toolchain on the consumer path (#7547) 2026-07-28 18:50:38 -07:00
test_mac_intel_compat.sh Fix Windows installer torch index override (#6972) 2026-07-09 03:46:47 -07:00
test_macos_clt_gate.sh Installer: stop requiring a developer toolchain on the consumer path (#7547) 2026-07-28 18:50:38 -07:00
test_node_decision.sh Studio: use an isolated Node.js for the frontend build instead of replacing the system Node/npm (#6533) 2026-06-21 21:17:29 -07:00
test_nvcc_meets_llama_minimum.sh Windows installer: fix DiskPart UAC mid-install, drive-root cache, and spurious unsloth.exe rename warning (#6296) 2026-06-22 03:09:08 -07:00
test_previous_torch_pin.sh install.sh: route Strix to the AMD arch index on rocm7.2 (#7264) + PCI detection hint (#7293) 2026-07-21 19:40:59 -07:00
test_redact_install_output.sh install: let UNSLOTH_TORCH_INDEX_FAMILY / _URL override CUDA wheel detection (#6692) 2026-07-20 00:58:52 -07:00
test_resolve_cuda_archs.sh studio/setup.sh: guard empty CUDA arch detection in the source build (#5854) (#6481) 2026-06-23 01:26:43 -07:00
test_staged_validation_enabled.sh fix(studio): opt-in source-build GPU smoke validation (#7322) 2026-07-23 19:13:54 -07:00
test_strixhalo_wsl_reroute.sh Studio: add UNSLOTH_SKIP_AUTOSTART installer flag (#7093) 2026-07-12 21:23:14 -07:00
test_studio_home_node_dir.sh Studio: use an isolated Node.js for the frontend build instead of replacing the system Node/npm (#6533) 2026-06-21 21:17:29 -07:00
test_system_node_readonly.sh Studio: use an isolated Node.js for the frontend build instead of replacing the system Node/npm (#6533) 2026-06-21 21:17:29 -07:00
test_tauri_install_exit_order.sh Windows installer: fix DiskPart UAC mid-install, drive-root cache, and spurious unsloth.exe rename warning (#6296) 2026-06-22 03:09:08 -07:00
test_tauri_retry_failure_context.sh Surface actionable installer failures in Studio desktop (#7529) 2026-07-28 10:19:44 +02:00
test_torch_constraint.sh tests: stop the installer constraint test counting occurrences (#7503) 2026-07-27 06:42:20 -07:00
test_torch_flavor.sh install: let UNSLOTH_TORCH_INDEX_FAMILY / _URL override CUDA wheel detection (#6692) 2026-07-20 00:58:52 -07:00
test_uninstall_shared_icon.sh Windows installer: fix DiskPart UAC mid-install, drive-root cache, and spurious unsloth.exe rename warning (#6296) 2026-06-22 03:09:08 -07:00
test_unsloth_torch_override.sh Installer: restore interrupted updates and clean stale rollback environments (#7342) 2026-07-23 01:29:53 -07:00
test_with_llama_cpp_dir_flag.sh [Studio] Add --with-llama-cpp-dir installer flag to reuse a local llama.cpp (#6472) 2026-07-02 22:11:20 +01:00
test_with_llama_cpp_dir_link_behavior.sh Surface actionable installer failures in Studio desktop (#7529) 2026-07-28 10:19:44 +02:00