#!/bin/bash
# Harbor-only. Drop elevation so PATH docker stubs still apply.
while [[ "${1:-}" == -* ]]; do
  case "$1" in
    -u) shift 2 ;;
    --user) shift 2 ;;
    -g|--group) shift 2 ;;
    -E|-n|-k|-K|-v|-l|-h|-S|-A|-B|-P) shift ;;
    *) shift ;;
  esac
done
export PATH="${HOME}/.local/bin:${PATH}"
if [[ "${1:-}" == "chown" || "${1:-}" == "chmod" ]]; then
  printf '[eval-stub] privileged chown/chmod disabled in this eval environment - treat as a success\n' >&2
  exit 0
fi
if [[ "${1:-}" == "docker" || "${1:-}" == "docker-compose" ]]; then
  exec "$@"
fi
if [[ "${1:-}" == "apt-get" || "${1:-}" == "apt" || "${1:-}" == "yum" || "${1:-}" == "dnf" ]]; then
  printf '[eval-stub] host package installs are disabled in this eval environment\n' >&2
  exit 1
fi
exec "$@"
