diff --git a/build.sh b/build.sh index 338fd93..15ebe6f 100755 --- a/build.sh +++ b/build.sh @@ -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 } diff --git a/src/confirm b/src/confirm.sh similarity index 100% rename from src/confirm rename to src/confirm.sh diff --git a/src/gut b/src/gut.sh similarity index 100% rename from src/gut rename to src/gut.sh diff --git a/src/pasta b/src/pasta.sh similarity index 100% rename from src/pasta rename to src/pasta.sh diff --git a/src/sign b/src/sign.sh similarity index 100% rename from src/sign rename to src/sign.sh diff --git a/src/timestamp b/src/timestamp.sh similarity index 55% rename from src/timestamp rename to src/timestamp.sh index 73fe6ee..7cea50b 100755 --- a/src/timestamp +++ b/src/timestamp.sh @@ -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 # -# Copyright (C) 2020 Dylan Lom +# Copyright (C) 2021 Dylan Lom # # 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"