Use .sh file extension in src/

* Re-write timestamp in sh instead of tcl
This commit is contained in:
Dylan Lom 2021-04-24 13:49:27 +10:00
parent 207a824e75
commit c28f163394
6 changed files with 27 additions and 22 deletions

View File

@ -21,9 +21,9 @@ cbuild() {
(set -x; cc $CFLAGS -o "$targetdest" "$target" src/util.c "$@")
}
fbuild() {
shbuild() {
target="$1"
targetdest="bin/$(prettyname "$target")"
targetdest="bin/$(prettyname "$target" | sed 's/\.sh$//')"
(set -x; cp "$target" "$targetdest")
}
@ -35,8 +35,8 @@ bin() {
cbuild "$f"
done
for f in src/pasta src/sign src/timestamp src/confirm; do
fbuild "$f"
for f in src/*.sh; do
shbuild "$f"
done
}

View File

View File

@ -1,9 +1,9 @@
#!/usr/bin/env tclsh
#!/usr/bin/env sh
#
# timestamp: print current date-timestamp
# author: djl
# timestamp: print current date-time(stamp)
# author: Dylan Lom <djl@dylanlom.com>
#
# Copyright (C) 2020 Dylan Lom <djl@dylanlom.com>
# Copyright (C) 2021 Dylan Lom <djl@dylanlom.com>
#
# Permission to use, copy, modify, and/or distribute this software for any purpose
# with or without fee is hereby granted.
@ -18,21 +18,26 @@
#
# flags:
# -d date only.
# -r rfc3339 except it's missing the colon in offset /shrug.
# -r rfc3339 without a colon in offset.
# -R rfc3339
# -v verbose human readable.
# human readable.
proc die {{msg "USAGE: $argv0 \[-d|r|v\]"}} {
puts stderr $msg
exit 1
# -h display help
# * human readable.
argv0="$0"
usage() {
echo "USAGE: $argv0 [-d|-r|-R|-v|-h]" > /dev/stderr
exit 1
}
switch [lindex $argv 0] {
-d { set fmt "%Y-%m-%d" }
-r { set fmt "%Y-%m-%dT%T%z" }
-v { set fmt "%Y-%m-%d %T %Z" }
{} { set fmt "%Y-%m-%d %H:%M" }
default die
}
puts [clock format [clock seconds] -format $fmt];
case "$1" in
'-h') usage ;;
'-d') fmt='%Y-%m-%d';;
'-r') fmt='%Y-%m-%dT%T%z' ;;
'-R') fmt='%Y-%m-%dT%T%:z' ;;
'-v') fmt='%Y-%m-%d %T %Z';;
*) fmt='%Y-%m-%d %H:%M';;
esac
date "+$fmt"