#!/bin/ksh
#
# $Revision: 70aa67e457e6 $ $Date: Thu, 21 Mar 2024 17:02:44 -0400 $
# $Source: /doc/html/htdocs/dotfiles/cron/newcmdlog $
# $Host: furbag $
# $UUID: 6afb4c65-30bd-4f3e-9cce-88627517fde2 $
#
#< newcmdlog: create new file for logging commands.

export PATH=/usr/local/bin:/sbin:/bin:/usr/bin
tag=${0##*/}
top="$HOME/.log"

die () { echo "$tag: $@" >& 2; exit 1; }

# Sanity checks.
test -d $top || mkdir $top || die "$top: not a directory"

chmod 700 $top
cd $top || die "$top: cannot cd"

# Create year directory.
set X $(date '+%Y %m%d')
case "$#" in
    3) yr=$2; day=$3 ;;
    *) die "date botch: $*" ;;
esac

test -d $yr || mkdir -p $yr || die "$yr: not a directory"
touch $yr/$day
rm -f today
ln $yr/$day today

exit 0
