This commit is contained in:
2025-03-21 10:51:17 +10:00
commit 1139e086fc
76 changed files with 2715 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
#!/bin/bash
# Usage: run_wordle.sh answer guess-file [-lines n] [args]
# Runs wordle with the given word as the answer with stdin redirected from
# the given guess file (one guess per line).
# If the -lines argument is given, then only the given number of lines
# from standard output will be saved - others will be discarded.
# Additional args are given as command line arguments to wordle.
if [ "$#" -lt 2 ] ; then
echo "Insufficient arguments to $0" >&2
exit 1
fi
if [ ! -r "$2" ] ; then
echo "Can't read guesses file \"$2\"" >&2
exit 2
fi
answer="$1"
guesses="$2"
shift 2
if [ "$1" = "-lines" -a -n "$2" ] ; then
lines="$2"
truncatemsg=0
shift 2;
else
# We truncate output after 200 lines - more than enough
lines=200
truncatemsg=1
fi
export WORD2310="${answer}"
# Run the program and only output the first $lines lines.
${wordle:=./wordle-debug} "$@" < ${guesses} | \
awk "NR<=${lines} \
{print \$0} \
NR==${lines}+1&&${truncatemsg} \
{print \"Output truncated - exceeds ${lines} lines\"}"
# Get wordle's exit status (first command in the pipeline)
status=${PIPESTATUS[0]}
exit $status