#!/bin/ksh
#
# $Revision: 1.4 $ $Date: 2012-07-26 17:11:48-04 $
# $Source: /home/vogelke/bin/RCS/mkrcs,v $
# $Host: sys7.com $
# $UUID: 23ae031f-d0f4-3f55-a8ed-4498bcf25ac3 $
#
#<mkrcs: write nice RCS info block to stdout or a file.
# Accepts optional filename as an argument.
#
# Usage:
#    me% mkrcs >> file && ci file && co file && ident file
#    file:
#         $ Revision: 1.1 $
#         $ Date: 2009/10/20 15:12:11 $
#         $ Source: /path/to/file/RCS/file,v $
#         $ Host: example.com $
#         $ UUID: f769a56e-3724-4e3b-a49d-577388070195 $

PATH=/usr/local/bin:/usr/bin:/bin:$HOME/bin
export PATH

# Handle cases where we have to look up the host or domain names,
# and cases where the hostname includes the domain.
case "$HOST" in
    "") HOST=$(hostname) ;;
    *)  ;;
esac

case "$HOST" in
    *.*) fqdn="$HOST"
         ;;

    *)   case "$DOMAIN" in
             "") DOMAIN=$(domainname) ;;
             *)  ;;
         esac
         fqdn="$HOST.$DOMAIN"
         ;;
esac

# If we have a file on the command line, append to it.
case "$#" in
    0) src="$(pwd)/MKRCS,v" ;;
    *) src="$1,v"; exec 1>> "$1" ;;
esac

tr '@' '$' <<EOF
#
# @Revision: 1.1 @ @Date: $(date -u '+%Y/%m/%d %H:%M:%S') @
# @Source: $src @
# @Host: $fqdn @
# @UUID: $(uuid) @
#
EOF

exit 0
