Commits

Cameron Simpson  committed 31ff891

buglog-daily: portable use of date(1) if no -D option

  • Participants
  • Parent commits 31f8fc3

Comments (0)

Files changed (1)

File bin/buglog-daily

 cmd=`basename "$0"`
 usage="Usage: $cmd [-D when] [-d logdir] headline"
 
-when=today
+when=
 logdir=$LOGDIR/daily
 
 badopts=
 
 [ $badopts ] && { echo "$usage" >&2; exit 2; }
 
-daycode=`date -d "$when" "+%Y-%m-%d"`
-hhmm=`date -d "$when" "+%H:%M"`
+if [ -n "$when" ]
+then
+  # not portable - needs GNU date :-(
+  daycode=`date -d "$when" "+%Y-%m-%d"`
+  hhmm=`date -d "$when" "+%H:%M"`
+else
+  daycode=`date "+%Y-%m-%d"`
+  hhmm=`date "+%H:%M"`
+fi
 logdir=$logdir/$daycode
 
 [ -d "$logdir/." ] || mkdir -- "$logdir"