File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -424,7 +424,7 @@ set -e
424424# Handle both direct execution and symlinked scenarios
425425if [ -L "$0" ]; then
426426 # Follow symlink
427- SCRIPT_PATH="$(readlink "$0" 2>/dev/null || readlink -f "$0" 2>/dev/null || echo "$0")"
427+ SCRIPT_PATH="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"
428428else
429429 SCRIPT_PATH="$0"
430430fi
Original file line number Diff line number Diff line change @@ -447,6 +447,37 @@ test_wrapper_via_symlink() {
447447 teardown
448448}
449449
450+ # ── Tests: wrapper via relative symlink from different directory ──
451+
452+ test_wrapper_via_relative_symlink () {
453+ printf ' %b\n' " ${C_BOLD} Wrapper works via relative symlink from different directory${C_RESET} "
454+ setup
455+
456+ prefix=" $TEST_TMPDIR /devcontainers"
457+ cli_version=" 0.75.0"
458+
459+ sh " $INSTALL_SCRIPT " --prefix " $prefix " --version " $cli_version " > /dev/null 2>&1
460+
461+ # Create a RELATIVE symlink in a different directory
462+ link_dir=" $TEST_TMPDIR /bin"
463+ mkdir -p " $link_dir "
464+
465+ # Create relative symlink that points back to the wrapper
466+ ln -s ../devcontainers/bin/devcontainer " $link_dir /devcontainer"
467+ assert_symlink " $link_dir /devcontainer" " relative symlink created"
468+
469+ # Call from a different directory
470+ cwd_before=$( pwd)
471+ cd " $TEST_TMPDIR "
472+ version_output=$( " $link_dir /devcontainer" --version 2> /dev/null) && wrc=0 || wrc=$?
473+
474+ cd " $cwd_before "
475+ assert_exit_code " 0" " $wrc " " relative symlink works from different directory"
476+ assert_contains " $version_output " " $cli_version " " relative symlink wrapper reports version"
477+
478+ teardown
479+ }
480+
450481# ── Tests: install to path with spaces ────────────────────────────
451482
452483test_path_with_spaces () {
You can’t perform that action at this time.
0 commit comments