]> Sergey Matveev's repositories - t.git/blobdiff - t
Raise copyright years
[t.git] / t
diff --git a/t b/t
index a1fcfc5ecf353914de6403b5f34dd897180a60c1..d6c5e57cd2b476cbada716a4c4e4156ba7f53deb 100755 (executable)
--- a/t
+++ b/t
@@ -1,6 +1,6 @@
 #!/usr/bin/env zsh
 # t -- simple notes manager
-# Copyright (C) 2013-2021 Sergey Matveev <stargrave@stargrave.org>
+# Copyright (C) 2013-2023 Sergey Matveev <stargrave@stargrave.org>
 # Current version is written on zsh. Previous was on POSIX shell.
 #
 # Usage:
@@ -36,6 +36,7 @@ purge() {
 }
 
 get_note() {
+    [[ "$1" = [0-9]* ]] || { print invalid note id ; exit 1 }
     NOTE=($NOTES_DIR/*(.on[$(( $1 + 1 ))]))
     [[ ${#NOTE} -eq 0 ]] && { print note not found >&2 ; exit 1 }
     NOTE=${NOTE[1]}
@@ -50,14 +51,15 @@ get_note() {
         [[ ${#line} -le 70 ]] || print -n "... "
         lines=$(wc -l < $note)
         printf "(%d)\n" $lines
-        ctr=$(( ctr + 1 ))
+        (( ctr = ctr + 1 ))
     }
     exit
 }
 
 case $1 in
 (a)
-    note=$NOTES_DIR/$(date "+%Y%m%d-%H%M%S")
+    zmodload -F zsh/datetime b:strftime
+    note=$NOTES_DIR/$(strftime %Y%m%d-%H%M%S)
     [[ $# -gt 1 ]] && print -- ${@[2,-1]} > $note || $EDITOR $note
     ;;
 (d) get_note $2 ; rm -f $NOTE ;;