Browse Source

Use .sh file extension in src/

* Re-write timestamp in sh instead of tcl
master
Dylan Lom 3 months ago
parent
commit
c28f163394
  1. 8
      build.sh
  2. 0
      src/confirm.sh
  3. 0
      src/gut.sh
  4. 0
      src/pasta.sh
  5. 0
      src/sign.sh
  6. 39
      src/timestamp.sh

8
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
}

0
src/confirm → src/confirm.sh

0
src/gut → src/gut.sh

0
src/pasta → src/pasta.sh

0
src/sign → src/sign.sh

39
src/timestamp → 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 <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"
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
usage() {
echo "USAGE: $argv0 [-d|-r|-R|-v|-h]" > /dev/stderr
exit 1
}
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"
Loading…
Cancel
Save