#!/usr/bin/env bash
# Convenience launcher for Ghidra's headless analyzer.
# The host package ships the support scripts WITHOUT the execute bit and owned
# by 'nobody', so they must be invoked through bash (see CREATING_A_GHIDRA_PROJECT.md).
set -u
target=${GHIDRA_INSTALL_DIR:-/usr/share/ghidra}/support/analyzeHeadless
if [ ! -r "$target" ]; then
    echo "analyzeHeadless: Ghidra is not available in this container." >&2
    echo "  expected: $target" >&2
    echo "  Ghidra is bind-mounted from the host, not installed in the image." >&2
    echo "  Start the box with --ghidra (or --re), or set 'ghidra = true' in the config." >&2
    exit 127
fi
exec bash "$target" "$@"
