Bash · Techniques
Branch with if
decide --quiet prints nothing. Its exit code is the answer. The function asks_for_refund names what that code means, and if reads it directly.
The ticket asks for a refund. The if branch picks the refunds queue.
question="Does the customer ask for a refund?"
ticket=$(cat <<'EOF'
I renewed once this morning, but my card shows two charges.
Please refund the duplicate.
EOF
)
asks_for_refund() {
printf '%s\n' "$1" |
thinkthen decide "$question" --quiet
}
if asks_for_refund "$ticket"; then
queue="refunds"
else
queue="support"
fi
test "$queue" = "refunds"No outputexit 0
On GitHub: github.com/botassembly/thinkthen