When writing run/config scripts, prefer local, opt-in environment changes and guarded defaults.
Rules
~/.bashrc/~/.profile). If you need PATH changes, set them for the current process only (e.g., export PATH=... inside the script).Example pattern
#!/usr/bin/env bash
set -euo pipefail
# Local PATH change (no ~/.bashrc mutation)
if command -v uv &>/dev/null; then :; else
curl -LsSf https://astral.sh/uv/install.sh | sh
fi
export PATH="$HOME/.local/bin:$PATH"
# Conditional system dependency (only if missing)
if ! dpkg -s python3-dev &>/dev/null; then
echo "Installing python3-dev (needed for Python.h during compilation)"
sudo apt-get update && sudo apt-get install -y python3-dev
fi
# Hardware override: opt-in via env var
# e.g. export HSA_OVERRIDE_GFX_VERSION=11.0.0 before running if needed
: "${HSA_OVERRIDE_GFX_VERSION:=}"
if [ -n "${HSA_OVERRIDE_GFX_VERSION}" ]; then
export HSA_OVERRIDE_GFX_VERSION
fi
exec python3 -m your_program "$@"
Applying this standard reduces cross-environment breakage (VM/container/bare metal), prevents unintended side effects on developers’ shells, and avoids configuration values that can harm unsupported hardware.
Enter the URL of a public GitHub repository