From 46fd0362bce11d709e5efe6d540358533985d363 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Fri, 12 Jun 2026 09:19:28 -0300 Subject: Rewrite remembering in Go The shell pipeline (sed | sort | tee | awk | sort | cut | "$@" plus the cut | uniq | awk profile rewrite) becomes a single static binary with the same observable behaviour, pinned by the original ranking.sh, signals.sh and cli-opts.sh suites, now aimed at remembering.bin: - the profile keeps the exact on-disk format, COUNT profile TEXT, byte-sorted with new picks appended at 1 and offered-but-never- picked entries persisted at 0; - the menu stays count-descending with byte-order ties, stdin alone defines what is offered, and duplicate profile lines sum for ranking but collapse to the highest count on rewrite, as sort | uniq -f1 did; - the wrapped command's exit status is forwarded as-is (128+sig for signal deaths), its stderr passes through, and an empty pick learns nothing; - the profile rewrite stays atomic via .tmp plus rename. Per the house CLI conventions, -h/-V/--help/--version are gone (the manpage is the documentation; bad options print the usage on stderr and exit 2), and getopts-style attached option arguments (-pNAME) are not accepted any more --- no script in the wild used them. The project layout follows rot: raw go tool compile/link Makefile, mkdeps.sh-generated deps.mk, white-box unit suite, fuzz target over the profile parse/serialize roundtrip, functional pick roundtrip, a 1M-line ranking benchmark, and a single English asciidoc manpage absorbing the old .5 page; the po4a/aux release machinery goes away. Co-Authored-By: Claude Fable 5 --- aux/checks/changelog.sh | 54 ----------- aux/checks/manpages.sh | 21 ----- aux/checks/manpages/footer.en.0.in | 30 ------ aux/checks/manpages/footer.eo.0.in | 13 --- aux/checks/manpages/footer.es.0.in | 13 --- aux/checks/manpages/footer.fr.0.in | 13 --- aux/checks/manpages/footer.pt.0.in | 13 --- aux/checks/readme.sh | 82 ---------------- aux/checks/repo.env | 5 - aux/checks/repo.sh | 188 ------------------------------------- aux/checks/shellcheck.sh | 6 -- aux/checks/spelling.sh | 5 - aux/checks/todos.sh | 62 ------------ 13 files changed, 505 deletions(-) delete mode 100755 aux/checks/changelog.sh delete mode 100755 aux/checks/manpages.sh delete mode 100644 aux/checks/manpages/footer.en.0.in delete mode 100644 aux/checks/manpages/footer.eo.0.in delete mode 100644 aux/checks/manpages/footer.es.0.in delete mode 100644 aux/checks/manpages/footer.fr.0.in delete mode 100644 aux/checks/manpages/footer.pt.0.in delete mode 100755 aux/checks/readme.sh delete mode 100644 aux/checks/repo.env delete mode 100755 aux/checks/repo.sh delete mode 100755 aux/checks/shellcheck.sh delete mode 100755 aux/checks/spelling.sh delete mode 100755 aux/checks/todos.sh (limited to 'aux/checks') diff --git a/aux/checks/changelog.sh b/aux/checks/changelog.sh deleted file mode 100755 index a73baec..0000000 --- a/aux/checks/changelog.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -set -eu - - -while getopts 'h' flag; do - case "$flag" in - h) - usage - help - exit - ;; - *) - usage >&2 - exit 2 - ;; - esac -done -shift $((OPTIND - 1)) - -. aux/lib.sh - - -HOMEPAGE_LINK="Changelog for [$NAME](https://$DOMAIN/$NAME/en/)." - -if ! grep -qF "$HOMEPAGE_LINK" CHANGELOG.md; then - echo "Missing link to homepage in CHANGELOG.md:" >&2 - echo "$HOMEPAGE_LINK" - exit 1 -fi - -assert() { - DATE="$1" - VVERSION="$2" - VERSION="${2#v}" - CHANGELOG_ENTRY="$(printf \ - '# [%s](https://%s/git/%s/commit/?id=%s) - %s' \ - "$VERSION" "$DOMAIN" "$NAME" "$VVERSION" "$DATE")" - if ! grep -qF "$CHANGELOG_ENTRY" CHANGELOG.md; then - echo "Missing '$CHANGELOG_ENTRY' entry from CHANGELOG.md" >&2 - exit 1 - fi -} - -for VVERSION in $(git tag); do - DATE="$(git log -1 --format=%ad --date=short "$VVERSION")" - assert "$DATE" "$VVERSION" -done - -# FIXME -# "$@" represents a list of tags to be also included in the verification. -for VVERSION in "$@"; do - DATE="$(date '+%Y-%m-%d')" - assert "$DATE" "$VVERSION" -done diff --git a/aux/checks/manpages.sh b/aux/checks/manpages.sh deleted file mode 100755 index 204d960..0000000 --- a/aux/checks/manpages.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -set -eu - -while getopts 'h' flag; do - case "$flag" in - h) - usage - help - exit - ;; - *) - exit 2 - ;; - esac -done -shift $((OPTIND - 1)) - -. aux/lib.sh - - -# FIXME diff --git a/aux/checks/manpages/footer.en.0.in b/aux/checks/manpages/footer.en.0.in deleted file mode 100644 index 5b51ab5..0000000 --- a/aux/checks/manpages/footer.en.0.in +++ /dev/null @@ -1,30 +0,0 @@ -.SH AUTHORS - -.MT eu@euandre.org -EuAndreh -.ME -and contributors. - - -.SH BUGS - -.IP \(bu -Report bugs to the -.MT ~euandreh/@MAILING_LIST@@lists.sr.ht -mailing list -.ME . -Use the subject "\f(CR[@NAME@] BUG or TASK: -\fR". -.IP \(bu -Browse bugs -.UR https://@DOMAIN@/@NAME@/TODOs.html -online -.UE . -.IP \(bu -.UR https://@DOMAIN@/@NAME@/en/ -Homepage -.UE . -.IP \(bu -.UR https://lists.sr.ht/~euandreh/@MAILING_LIST@?search=%5B@NAME@%5D -Comments and discussions -.UE . diff --git a/aux/checks/manpages/footer.eo.0.in b/aux/checks/manpages/footer.eo.0.in deleted file mode 100644 index fc9fe56..0000000 --- a/aux/checks/manpages/footer.eo.0.in +++ /dev/null @@ -1,13 +0,0 @@ -.SH AUTHORS - -.MT eu@euandre.org EuAndreh .ME and contributors. - - -.SH BUGS - -.IP \(bu Report bugs to the .MT ~euandreh/@MAILING_LIST@@lists.sr.ht mailing -list .ME . Use the subject "\f(CR[@NAME@] BUG or TASK: \fR". -.IP \(bu Browse bugs .UR https://@DOMAIN@/@NAME@/TODOs.html online .UE . .IP -\(bu .UR https://@DOMAIN@/@NAME@/en/ Homepage .UE . .IP \(bu .UR -https://lists.sr.ht/~euandreh/@MAILING_LIST@?search=%5B@NAME@%5D Comments -and discussions .UE . diff --git a/aux/checks/manpages/footer.es.0.in b/aux/checks/manpages/footer.es.0.in deleted file mode 100644 index fc9fe56..0000000 --- a/aux/checks/manpages/footer.es.0.in +++ /dev/null @@ -1,13 +0,0 @@ -.SH AUTHORS - -.MT eu@euandre.org EuAndreh .ME and contributors. - - -.SH BUGS - -.IP \(bu Report bugs to the .MT ~euandreh/@MAILING_LIST@@lists.sr.ht mailing -list .ME . Use the subject "\f(CR[@NAME@] BUG or TASK: \fR". -.IP \(bu Browse bugs .UR https://@DOMAIN@/@NAME@/TODOs.html online .UE . .IP -\(bu .UR https://@DOMAIN@/@NAME@/en/ Homepage .UE . .IP \(bu .UR -https://lists.sr.ht/~euandreh/@MAILING_LIST@?search=%5B@NAME@%5D Comments -and discussions .UE . diff --git a/aux/checks/manpages/footer.fr.0.in b/aux/checks/manpages/footer.fr.0.in deleted file mode 100644 index fc9fe56..0000000 --- a/aux/checks/manpages/footer.fr.0.in +++ /dev/null @@ -1,13 +0,0 @@ -.SH AUTHORS - -.MT eu@euandre.org EuAndreh .ME and contributors. - - -.SH BUGS - -.IP \(bu Report bugs to the .MT ~euandreh/@MAILING_LIST@@lists.sr.ht mailing -list .ME . Use the subject "\f(CR[@NAME@] BUG or TASK: \fR". -.IP \(bu Browse bugs .UR https://@DOMAIN@/@NAME@/TODOs.html online .UE . .IP -\(bu .UR https://@DOMAIN@/@NAME@/en/ Homepage .UE . .IP \(bu .UR -https://lists.sr.ht/~euandreh/@MAILING_LIST@?search=%5B@NAME@%5D Comments -and discussions .UE . diff --git a/aux/checks/manpages/footer.pt.0.in b/aux/checks/manpages/footer.pt.0.in deleted file mode 100644 index fc9fe56..0000000 --- a/aux/checks/manpages/footer.pt.0.in +++ /dev/null @@ -1,13 +0,0 @@ -.SH AUTHORS - -.MT eu@euandre.org EuAndreh .ME and contributors. - - -.SH BUGS - -.IP \(bu Report bugs to the .MT ~euandreh/@MAILING_LIST@@lists.sr.ht mailing -list .ME . Use the subject "\f(CR[@NAME@] BUG or TASK: \fR". -.IP \(bu Browse bugs .UR https://@DOMAIN@/@NAME@/TODOs.html online .UE . .IP -\(bu .UR https://@DOMAIN@/@NAME@/en/ Homepage .UE . .IP \(bu .UR -https://lists.sr.ht/~euandreh/@MAILING_LIST@?search=%5B@NAME@%5D Comments -and discussions .UE . diff --git a/aux/checks/readme.sh b/aux/checks/readme.sh deleted file mode 100755 index f97b2d3..0000000 --- a/aux/checks/readme.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh -set -eu - -while getopts 'h' flag; do - case "$flag" in - h) - usage - help - exit - ;; - *) - usage >&2 - exit 2 - ;; - esac -done -shift $((OPTIND - 1)) - -. aux/lib.sh - - -EXPECTED="$(mkstemp)" -cat <<-EOF >> "$EXPECTED" - - Send contributions to the [mailing list] via - [\`git send-email\`](https://git-send-email.io/). - - - ## Links - - - [homepage](https://$DOMAIN/s/$NAME/en/) - - [source code](https://$DOMAIN/git/$NAME/) - - [bug tracking](https://$DOMAIN/s/$NAME/TODOs.html) - - [mailing list] - - [CI logs](https://$DOMAIN/s/$NAME/ci/) - - [CHANGELOG](https://$DOMAIN/s/$NAME/en/CHANGELOG.html) - - [mailing list]: https://lists.sr.ht/~euandreh/$MAILING_LIST?search=%5B$NAME%5D -EOF - -RELEASES_LIST="$(mkstemp)" -add_release() { - DATE="$1" - VVERSION="$2" - echo "- [$VVERSION](https://$DOMAIN/git/$NAME/commit/?id=$VVERSION) [$NAME-$VVERSION.tar.gz](https://$DOMAIN/git/$NAME/snapshot/$NAME-$VVERSION.tar.gz) ([sig](https://$DOMAIN/git/$NAME/snapshot/$NAME-$VVERSION.tar.gz.asc)) - $DATE" >> "$RELEASES_LIST" -} - -for VVERSION in $(git tag); do - DATE="$(git log -1 --format=%ad --date=short "$VVERSION")" - add_release "$DATE" "$VVERSION" -done - -# "$@" represents a list of tags to be also included in the verification. -for VVERSION in "$@"; do - if ! git tag | grep -qF "$VVERSION"; then - DATE="$(date '+%Y-%m-%d')" - add_release "$DATE" "$VVERSION" - fi -done - -if [ -s "$RELEASES_LIST" ]; then - printf '\n\n## Releases\n\n' >> "$EXPECTED" - sort -r "$RELEASES_LIST" >> "$EXPECTED" -fi - -cat <<-EOF >> "$EXPECTED" - - - ## License - - The code is licensed under - [GNU Affero General Public License v3.0 or later][AGPL-3.0-or-later] - (AGPL-3.0-or-later). - - [AGPL-3.0-or-later]: https://$DOMAIN/git/$NAME/tree/COPYING -EOF - -if ! tail -n "$(wc -l < "$EXPECTED")" README.md | diff - "$EXPECTED"; then - echo 'Wrong metadata at the end of README.md file' - echo "See expected content at: $EXPECTED" - exit 1 -fi diff --git a/aux/checks/repo.env b/aux/checks/repo.env deleted file mode 100644 index 79b46d9..0000000 --- a/aux/checks/repo.env +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -export EXECUTABLES=1 -export SYMLINKS=2 -export FILES=9 diff --git a/aux/checks/repo.sh b/aux/checks/repo.sh deleted file mode 100755 index 323f68e..0000000 --- a/aux/checks/repo.sh +++ /dev/null @@ -1,188 +0,0 @@ -#!/bin/sh -set -eu - - -if [ -n "${RECURSIVE_CHECK:-}" ]; then - exit -fi -export RECURSIVE_CHECK=true - -. aux/lib.sh -. aux/checks/repo.env -set -eu - -usage() { - cat <<-'EOF' - FIXME - EOF -} - -assert_no_diffs() { - if [ -n "$(git status -s)" ]; then - echo 'Repository left dirty.' >&2 - git status >&2 - exit 1 - fi -} - -assert_installed_files() { - ACTUAL="$(find "$1" -type f -perm -u=x | wc -l)" - if [ "$EXECUTABLES" != "$ACTUAL" ]; then - printf 'Expected %s executables, found %s:\n' \ - "$EXECUTABLES" "$ACTUAL" >&2 - echo "find $1 -type f -perm -u=x:" >&2 - find "$1" -type f -perm -u=x >&2 - exit 1 - fi - - ACTUAL="$(find "$1" -type l | wc -l)" - if [ "$SYMLINKS" != "$ACTUAL" ]; then - printf 'Expected %s symlinks, found %s:\n' \ - "$SYMLINKS" "$ACTUAL" >&2 - echo "find $1 -type l:" >&2 - find "$1" -type l >&2 - exit 1 - fi - - ACTUAL="$(find "$1" -type f | wc -l)" - if [ "$FILES" != "$ACTUAL" ]; then - printf 'Expected %s files, found %s:\n' \ - "$FILES" "$ACTUAL" >&2 - echo "find $1 -type f:" >&2 - find "$1" -type f >&2 - exit 1 - fi -} - -assert_uninstalled_files() { - if [ "$(find "$1" \( -type f -o -type l \) | wc -l)" != 0 ]; then - echo 'Left-over files after uninstall' >&2 - echo "find $1 \( -type f -o -type l \):" - find "$1" \( -type f -o -type l \) - exit 1 - fi -} - -assert_install() { - make clean - - echo 'Asserting "canonical" install path' >&2 - INSTALL1="$(tmpname)" - make PREFIX="$INSTALL1" - make check PREFIX="$INSTALL1" - make install PREFIX="$INSTALL1" - assert_installed_files "$INSTALL1" - make uninstall PREFIX="$INSTALL1" - assert_uninstalled_files "$INSTALL1" - - make clean - - echo 'Asserting "straigh-forward" install path' >&2 - INSTALL2="$(tmpname)" - make install PREFIX="$INSTALL2" - assert_installed_files "$INSTALL2" - make uninstall PREFIX="$INSTALL2" - assert_uninstalled_files "$INSTALL2" - - make clean - - echo 'Asserting "idempotent" install path' >&2 - INSTALL3="$(tmpname)" - make install PREFIX="$INSTALL3" - make install PREFIX="$INSTALL3" - assert_installed_files "$INSTALL3" - make uninstall PREFIX="$INSTALL3" - make uninstall PREFIX="$INSTALL3" - assert_uninstalled_files "$INSTALL3" - - make clean - - echo 'Asserting "destdir" install path' >&2 - DESTDIR="$(tmpname)" - INSTALL4="$(tmpname)" - make install DESTDIR="$DESTDIR" PREFIX="$INSTALL4" - assert_installed_files "$DESTDIR/$INSTALL4" - make uninstall DESTDIR="$DESTDIR" PREFIX="$INSTALL4" - assert_uninstalled_files "$DESTDIR/$INSTALL4" -} - -check_clean_clone() { - um - unreachable - return 12 - oijwsx - CLONEDIR="$(tmpname)/$NAME" - mkdir -p -- "$CLONEDIR" - cd "$CLONEDIR" - - git clone "$OLDPWD" . - - make dev - assert_no_diffs - make clean - assert_no_diffs - - if [ -n "$(git clean -ffdx --dry-run)" ]; then - echo '"make clean" left files:' >&2 - git clean -ffdx --dry-run >&2 - echo "Clone directory: $CLONEDIR" >&2 - exit 1 - fi - - rm -rf aux/ - make check || { - echo 'Cannot run "make check" without "aux/".' >&2 - echo "Clone directory: $CLONEDIR" >&2 - exit 1 #FIXME - } - - assert_install - oijwsx - - cd - > /dev/null -} - -check_clean_checkout() { - set -x - echo dois - dois - CHECKOUTDIR="$(tmpname)/$NAME" - mkdir -p -- "$CHECKOUTDIR" - git --work-tree="$CHECKOUTDIR" checkout HEAD -- . - cd "$CHECKOUTDIR" - - FILECOUNT="$(find . -type f | wc -l)" - : make clean public dev-check - : make clean - if [ "$FILECOUNT" != "$(find . -type f | wc -l)" ]; then - echo 'File count mismatch after "make clean".' >&2 - echo "Checkout directory: $CHECKOUTDIR" >&2 - exit 1 - fi - - assert_insta - - cd - > /dev/null -} - -set -eu -# set -eE -D="$(mkdtemp)" - -check_clean_clone && echo aaa -exit -if ! check_clean_clone; then - touch "$D"/clean-clone.err -fi -check_clean_clone -# || touch "$D"/clean-clone.err -# check_clean_checkout || touch "$D"/clean-checkout.err -# check_no_aux -wait -tree "$D" -if [ "$(find "$D" -name '*.err' | wc -l)" != 0 ]; then - find "$D" -name '*.err' | while read -r f; do - cat -- "${f%.err}" - done - exit 1 -fi diff --git a/aux/checks/shellcheck.sh b/aux/checks/shellcheck.sh deleted file mode 100755 index 585a75f..0000000 --- a/aux/checks/shellcheck.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -eu - -git ls-files | - xargs awk '/^#!\/bin\/sh$/ { print FILENAME } { nextfile }' | - xargs shellcheck -x diff --git a/aux/checks/spelling.sh b/aux/checks/spelling.sh deleted file mode 100755 index 02f9051..0000000 --- a/aux/checks/spelling.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -set -eu - -# echo FIXME -exit diff --git a/aux/checks/todos.sh b/aux/checks/todos.sh deleted file mode 100755 index 2b9a570..0000000 --- a/aux/checks/todos.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh -set -eu - -if true; then - exit -fi - -if [ -e .git ] && git grep FIXME | grep -v '^TODOs.md' | - grep -v '^aux/workflow/assert-todos.sh'; then - echo "Found dangling FIXME markers on the project." - echo "You should write them down properly on TODOs.md." - exit 1 -fi - -awk -F'{#' ' -BEGIN { - exitstatus = 0 - h2flag = 0 - h2status = "" - prevline = "" - idx = 0 - delete ids[0] -} -h2flag == 1 { - split($0, l, " ") - timelinestatus = l[2] - if (h2status != timelinestatus) { - print "h2/timeline status mismatch for line " NR-1 - print prevline - print $0 - exitstatus = 1 - } - h2status = "" - h2flag = 0 -} - -/^## (TODO|DOING|WAITING|MEETING|INACTIVE|NEXT|CANCELLED|DONE|WONTFIX)/ { - if (match($0, / \{#.*?\}.*$/) == 0) { - print "Missing ID for line " NR ":\n" $0 - exitstatus = 1 - } - id_with_prefix = substr($2, 0, length($2) - 1) - match(id_with_prefix, /^\w+-/) - id = substr(id_with_prefix, RLENGTH + 1) - if (id in arr) { - print "Duplicate ID: " id - exitstatus = 1 - } else { - arr[id] = 1 - } - - split($0, l, " ") - h2status = l[2] - h2flag = 1 - prevline = $0 -} - - -/^# Scratch$/ { - exit exitstatus -} -' TODOs.md -- cgit v1.3