Skip to content

Commit ce289e0

Browse files
t3dotggclaude
andcommitted
fix(install): install.sh works without SHELL and keeps its own link through a symlinked home
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f7029da commit ce289e0

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

‎scripts/install.sh‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,17 @@ mkdir -p "$bin_dir"
231231
if [ -e "${bin_dir}/t3" ] || [ -L "${bin_dir}/t3" ]; then
232232
existing="$(readlink "${bin_dir}/t3" 2>/dev/null || true)"
233233
real_versions_dir="$(CDPATH='' cd -P -- "$versions_dir" && pwd)"
234+
# Through a symlinked T3 home the link text names the alias; resolve its folder to compare.
235+
existing_dir="$(CDPATH='' cd -P -- "$(dirname -- "${existing:-.}")" 2>/dev/null && pwd || true)"
236+
resolved="${existing_dir}/${existing##*/}"
234237
case "$existing" in
235238
"$versions_dir"/* | "$real_versions_dir"/* | "${t3_home}/bin/t3") ;;
236-
*) fail "another t3 is already at ${bin_dir}/t3. Remove it and run this again, or run ${target_dir}/t3 directly." ;;
239+
*)
240+
case "$resolved" in
241+
"$real_versions_dir"/*) ;;
242+
*) fail "another t3 is already at ${bin_dir}/t3. Remove it and run this again, or run ${target_dir}/t3 directly." ;;
243+
esac
244+
;;
237245
esac
238246
fi
239247
ln -sfn "${target_dir}/t3" "${bin_dir}/t3"
@@ -252,7 +260,8 @@ case "$bin_dir" in "$HOME"/*) path_rest="${bin_dir#"$HOME"}" path_prefix='$HOME'
252260
case "$path_rest" in *[!A-Za-z0-9_./-]*) path_rest= ;; esac
253261
if [ -n "$path_rest" ]; then
254262
path_line="export PATH=\"${path_prefix}${path_rest}:\$PATH\""
255-
case "${SHELL##*/}" in
263+
shell_name="${SHELL:-}"
264+
case "${shell_name##*/}" in
256265
zsh) path_command="printf '\\n%s\\n' '${path_line}' >> ~/.zshrc" ;;
257266
bash) [ "$platform" = darwin ] || path_command="printf '\\n%s\\n' '${path_line}' >> ~/.bashrc" ;;
258267
fish) path_command="fish_add_path ${path_prefix}${path_rest}" ;;

‎scripts/install.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("install.sh t3
142142
`printf '\\n%s\\n' 'export PATH="$HOME/bin:$PATH"' >> ~/.zshrc`,
143143
);
144144

145+
// Containers and CI often have no SHELL; `set -u` must not stop the installer there.
146+
const noShell = await installOver({
147+
script: "install.sh",
148+
home,
149+
binDir,
150+
env: { HOME: root, SHELL: undefined, PATH: "/usr/bin:/bin" },
151+
});
152+
expect(noShell.code, noShell.output).toBe(0);
153+
expect(noShell.output).toContain(`Add ${binDir} to your PATH`);
154+
145155
await NodeFSP.rm(link);
146156
await NodeFSP.symlink(NodePath.join(home, "bin/t3"), link);
147157
const overDesktop = await installOver({ script: "install.sh", home, binDir });

0 commit comments

Comments
 (0)