#!/bin/sh -e
# Author: Brian Murray <brian@canonical.com>
# Copyright (C) 2009 Canonical, Ltd.
# License: GPLv3

loc=$(dirname "$0")

if [ "$1" != "--master" ]; then
    echo "Must specify --master BUG for duplicate master bug" >&2
    exit 1
else
    shift || true
    master="$1"
fi
if [ -z "$master" ]; then
    echo "Must specify master bug number" >&2
    exit 1
fi
shift || true

comment="Thank you for taking the time to report this bug and helping to make Ubuntu better. This particular bug has already been reported and is a duplicate of bug $master, so it is being marked as such. Please look at the other bug report to see if there is any missing information that you can provide, or to see if there is a workaround for the bug.  Additionally, any further discussion regarding the bug should occur in the other report.  Please continue to report any other bugs you may find."

for b in "$@"; do
    "$loc"/update-bug --status "Confirmed" --comment "$comment" --duplicate "$master" $b || {
        echo "ERROR with LP: #$b" >&2
    }
done

