#!/bin/bash
# ==========
# $File: //guest/amo/scripts/triggers/myDefaultChgDesc.sh $
# $Revision: #1 $
# $Change: 25064 $
#
# $Author: amo $
# #DateTimeTZ$
# ==========
# PURPOSE
# A trigger script that will replace the default change description.
# On form-out, it replaces the default "<enter description here>" with a preferred alternative.
# On form-in, it will reject the change if the new default description hasn't been replaced.
#
# Two trigger-table entries, as follows:
# chgdesc-out form-out change "%//scripts/triggers/myDefaultChgDesc.sh% output %formfile%"
# chgdesc-in form-in change "%//scripts/triggers/myDefaultChgDesc.sh% input %formfile%"
#
# ==========
# default descriptions
stdDesc="<enter description here>"
myDesc="Describe the purpose of this change"
direction=$1
formfile=$2
# switching on 'input' or 'output'
case $direction in
# form-in - check formfile for the replacement description
# if found, bail with non-zero error code.
# otherwise, the description has been changed and all is well (exit 0).
input)
grep -e "$myDesc" $formfile > /dev/null
err=$?
if [ $err = 0 ]; then
echo Description not changed.
exit 1
else
exit 0;
fi
;;
# form-out - using sed to replace the standard description in 'formfile' with my new description
output)
sed -i -e "s/$stdDesc/$myDesc/g" $formfile
exit $?
;;
# any other value for 'direction' is not known, so bail with a different non-zero error code.
*)
echo Error: unknown state \($direction\).
exit 2
;;
esac
Adding a trigger script that, in one form, will replace the default change description ('enter description here' in angle brackets) and in a second form check to ensure that new description has indeed been changed.