syntaxai/tdd.md · main · tools / sama-cli / sama
#!/usr/bin/env bash
# sama — entry wrapper for the SAMA v2 shell verifier. Locates
# src/d21_main.sh relative to this file, exports SAMA_SRC_DIR so
# the dispatcher can re-source its siblings, and delegates argv.
#
# This file is the public CLI surface. It is intentionally tiny —
# all dispatch logic lives in d21_main.sh (Layer 3 — Entry per the
# tools/sama-cli sub-profile).
set -u
# Resolve symlinks so the install layout `~/.local/bin/sama →
# ~/.sama-cli/sama` finds src/ next to the REAL file, not the
# symlink. POSIX-portable loop — `readlink -f` is GNU-only.
_sama_self="${BASH_SOURCE[0]:-$0}"
while [ -L "$_sama_self" ]; do
_sama_link="$(readlink "$_sama_self")"
case "$_sama_link" in
/*) _sama_self="$_sama_link" ;;
*) _sama_self="$(dirname "$_sama_self")/$_sama_link" ;;
esac
done
SAMA_BIN_DIR="$(cd "$(dirname "$_sama_self")" && pwd)"
export SAMA_SRC_DIR="$SAMA_BIN_DIR/src"
# shellcheck disable=SC1091
. "$SAMA_SRC_DIR/d21_main.sh"
sama_main "$@"