taskwarrior/test/test_hooks/on-add-modify
Dustin J. Mitchell c639cc030d
Fix and test handling of backslashes in hooks (#3909)
* Update hooks to use `read -r` and `printf`

This portably avoids any interpretation of backslash escapes by the
shell.

* Support running make_tc_task elsewhere

* Add a test for backslashes in task descriptions
2025-07-08 08:40:34 +02:00

21 lines
428 B
Bash
Executable file

#!/usr/bin/env bash
# Input:
# - Line of JSON for proposed new task.
read -r new_task
if (printf "%s\n" "$new_task" | grep -qE '[tT]eh');
then
new_task=$(printf "%s\n" "$new_task" | sed -r 's/([tT])eh/\1he/g')
fi
# Output:
# - JSON, modified
# - Optional feedback/error.
printf "%s\n" "$new_task"
echo 'FEEDBACK'
# Status:
# - 0: JSON accepted, non-JSON is feedback.
# - non-0: JSON ignored, non-JSON is error.
exit 0