#!/usr/bin/env bash
set -euo pipefail

args=()
skip_next=0

for arg in "$@"; do
  if [ "$skip_next" -eq 1 ]; then
    skip_next=0
    if [ "$arg" = "nvidia" ]; then
      continue
    fi
  fi

  if [ "$arg" = "--runtime" ]; then
    skip_next=1
    continue
  fi

  args+=("$arg")
done

exec /usr/bin/docker "${args[@]}"
