#!/bin/sh
"true" ''''
# Resolve $0 to its physical path inside a subshell so the cd's required to
# walk symlinks on macOS (which lacks `readlink -f` in /usr/bin pre-Big Sur)
# don't leak out and clobber the caller's working directory.  Without the
# subshell, every entry point produced by relenv on macOS started Python
# with cwd set to the install dir, breaking anything that resolved relative
# paths against os.getcwd() (Saltfile auto-discovery, --config-dir=./...,
# config_dir: ./..., etc).  See
# https://github.com/saltstack/relenv/issues/293.
REALPATH=$(
    TARGET_FILE=$0
    cd "$(dirname "$TARGET_FILE")" || exit
    TARGET_FILE=$(basename "$TARGET_FILE")
    while [ -L "$TARGET_FILE" ]
    do
        TARGET_FILE=$(readlink "$TARGET_FILE")
        cd "$(dirname "$TARGET_FILE")" || exit
        TARGET_FILE=$(basename "$TARGET_FILE")
    done
    echo "$(pwd -P)/$TARGET_FILE"
)
# shellcheck disable=SC2093
"exec" "$(dirname "$REALPATH")"/bin/python3.14 "$REALPATH" "$@"
' '''

import sys
from salt.scripts import salt_spm
if __name__ == '__main__':
    sys.argv[0] = sys.argv[0].removesuffix('.exe')
    sys.exit(salt_spm())
