mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-29 00:53:23 +02:00
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
This commit is contained in:
parent
7fdcdebd19
commit
c639cc030d
27 changed files with 115 additions and 75 deletions
|
@ -10,7 +10,7 @@ read -r new_task
|
|||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo "$new_task"
|
||||
printf "%s\n" "$new_task"
|
||||
echo 'on-add'
|
||||
|
||||
# Status:
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
read -r new_task
|
||||
|
||||
if (echo "$new_task" | grep -qE '[tT]eh');
|
||||
if (printf "%s" "$new_task" | grep -qE '[tT]eh');
|
||||
then
|
||||
new_task=$(echo "$new_task" | sed -r 's/([tT])eh/\1he/g')
|
||||
new_task=$(printf "%s" "$new_task" | sed -r 's/([tT])eh/\1he/g')
|
||||
echo "Auto-corrected 'teh' --> 'the'"
|
||||
fi
|
||||
|
||||
echo "$new_task"
|
||||
printf "%s" "$new_task"
|
||||
exit 0
|
||||
|
|
|
@ -12,8 +12,8 @@ read -r modified_task
|
|||
# Output:
|
||||
# - JSON, modified or unmodified.
|
||||
# - Optional feedback/error.
|
||||
echo "$modified_task"
|
||||
echo 'on-modify'
|
||||
printf "%s" "$modified_task"
|
||||
printf "%s" 'on-modify'
|
||||
|
||||
# Status:
|
||||
# - 0: JSON accepted, non-JSON is feedback.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue