#!/usr/bin/env sh
# Replace a symlink with a copy of the thing it points to
#
# (Req's coreutils.)

while getopts h opt; do
    case $opt in
    h) awk 'NR == 1 { next } /^$/ { exit } { print substr($0, 3) }' "$0"
       exit ;;
    esac
done
shift $(( OPTIND - 1 ))

if [ -L "$1" ]; then
    cp --remove-destination "$(readlink "$1")" "$1"
else
    exit 1
fi
