#!/usr/bin/env bash

in="$1"

if [[ -z "$in" ]]; then
  echo "usage: $0 input_file"
  exit 1
fi

while IFS= read -r line; do
  [[ -z "$line" || "$line" =~ ^# ]] && continue
  if [[ "$line" =~ ^([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]]; then
    var="${BASH_REMATCH[1]}"
    val="${BASH_REMATCH[2]}"
    val="${val%\"}"
    val="${val#\"}"
    echo "set -Ux $var \"$val\""
  fi
done < "$in"

