#!/bin/sh
set -e
BASHRC="${1:-/home/$USER/.bashrc}"

if [ -z "$BASHRC" ]; then
  echo "Usage: epc670-bashrc-remove <path-to-.bashrc>" >&2
  exit 1
fi
if [ ! -f "$BASHRC" ]; then
  echo "Error: bashrc not found at $BASHRC" >&2
  exit 1
fi
if ! grep -q "BEGIN epc670-tofhat-utils" "$BASHRC"; then
  exit 0
fi

sed -i '/# BEGIN epc670-tofhat-utils/,/# END epc670-tofhat-utils/d' "$BASHRC"