#!/bin/bash
VERSION=${1:-stable}
SOURCE="https://raw.githubusercontent.com/bestpractical/rt/$VERSION/bin/rt.in"

echo "Importing from $VERSION"
echo "Downloading..."
curl -s $SOURCE \
    | perl -pe 's,\@PERL\@.*$,/usr/bin/env perl,;s,\@LOCAL_ETC_PATH\@,/usr/local/etc,g;' > script/rt

if [[ $? == 0 ]]; then
    echo "Placeholders rewritten."
    echo
    echo "Please check the changes using \`git diff\`."
else
    echo "An error occurred!"
fi
