# toolset-cleanup.sh — Unset ENV vars for disabled language toolsets.
# shellcheck shell=bash
# Dockerfile ENV is unconditional; if a toolset was excluded via --lang,
# the vars point to non-existent paths. Unset them to prevent confusing
# build tool behavior.
# Copyright (c) 2026 Progralink. Licensed under the DevCage License — see LICENSE.

_cleanup_disabled_toolsets() {
    [ -x "${JAVA_HOME:-}/bin/java" ] 2>/dev/null || {
        unset JAVA_HOME MAVEN_HOME MAVEN_OPTS GRADLE_HOME GRADLE_OPTS 2>/dev/null || true
    }
    [ -x "${GOROOT:-}/bin/go" ] 2>/dev/null || {
        unset GOROOT GOPATH GOBIN 2>/dev/null || true
    }
    [ -d "${RUSTUP_HOME:-}/toolchains" ] 2>/dev/null || {
        unset RUSTUP_HOME 2>/dev/null || true
    }
}
