commit d74514ad6126cf8ebd1bbc4a48adb21d36eb80cf parent f4ea9fd39b6cee6339924c96c87a16d4b4f7f846 Author: Jacob R. Edwards <jacobouno@protonmail.com> Date: Sun, 14 Feb 2021 15:19:28 -0800 Polish the now script Diffstat:
| M | modules/scripts/.local/bin/now | | | 44 | ++++++++++++++++++++++++++------------------ |
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git a/modules/scripts/.local/bin/now b/modules/scripts/.local/bin/now @@ -1,22 +1,30 @@ -#!/usr/bin/env dash -#! now -- display system date and or time in an fs friendly format -#! -#! The -f flag is default, the flags are thus: `f' for full date and -#! time, `d' for date, and `t' for time. +#!/bin/sh +# Copywrite 2021 Jacob R. Edwards +# License: GPLv3 +# +# now -- get the current date and or time +# +# There are no special characters (to POSIX shells or the UNIX +# filesystem) making it easy to use for determining file names. The +# following commands are available, if none are given `full' is +# defaulted to: +# +# d[ate] Display the date +# t[ime] Display the time +# f[ull] Display the date and time -set -eu +time='%H%M%S' +date='%Y%m%d' -# strftime(3): -date="%Y%m%d" -time="%H%M%S" - -usage() { echo "usage: `basename $0` [-dft]" ;} -err() { echo "`basename $0`: $@" 1>&2 ;} - -case "${1:-"-f"}" +case ${1:-f} in - -d) date +$date;; - -f) date +$date-$time;; - -t) date +$time;; - *) err "'$1': unknown option."; usage; exit 1;; +(d|date) + date +$date;; +(t|time) + date +$time;; +(f|full) + date +$date-$time;; +(*) + printf 'usage: %s [-dft]\n' `basename $0` 1>&2 + exit 1 esac