Bash · Techniques
Fail a build
filter finds the lines that hedge. The script exits 1 when it finds any, and the build fails.
No line hedges. The check prints nothing and passes.
question="Does this sentence hedge?"
cat <<'EOF' > notes.txt
The export runs every night at two.
Failed rows go to a separate file.
Each row keeps its id.
EOF
thinkthen filter "$question" --batch 1 \
< notes.txt > hedges.txt
if [ -s hedges.txt ]; then
echo "These lines hedge:"
cat hedges.txt
exit 1
fiNo outputexit 0
One line hedges. The check prints it and exits 1.
question="Does this sentence hedge?"
cat <<'EOF' > notes.txt
The export runs every night at two.
It might possibly be worth considering a retry.
Each row keeps its id.
EOF
thinkthen filter "$question" --batch 1 \
< notes.txt > hedges.txt
if [ -s hedges.txt ]; then
echo "These lines hedge:"
cat hedges.txt
exit 1
fiOutput
These lines hedge: It might possibly be worth considering a retry.
exit 1
On GitHub: github.com/botassembly/thinkthen