mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-30 04:23:24 +02:00
Add shell quoting and 'read -r' in example hooks (#3905)
This helps to avoid interpretation of escape sequences, such as backslash-escapes, in these values. Patch provided by @bughunter2 in https://github.com/GothenburgBitFactory/taskwarrior/issues/3899.
This commit is contained in:
parent
c594ecb58d
commit
cf6c0254dc
5 changed files with 12 additions and 12 deletions
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
# Input:
|
# Input:
|
||||||
# - Line of JSON for proposed new task.
|
# - Line of JSON for proposed new task.
|
||||||
read new_task
|
read -r new_task
|
||||||
|
|
||||||
# Output:
|
# Output:
|
||||||
# - JSON, modified or unmodified.
|
# - JSON, modified or unmodified.
|
||||||
# - Optional feedback/error.
|
# - Optional feedback/error.
|
||||||
echo $new_task
|
echo "$new_task"
|
||||||
echo 'on-add'
|
echo 'on-add'
|
||||||
|
|
||||||
# Status:
|
# Status:
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
read new_task
|
read -r new_task
|
||||||
|
|
||||||
if (echo $new_task | grep -qE '[tT]eh');
|
if (echo "$new_task" | grep -qE '[tT]eh');
|
||||||
then
|
then
|
||||||
new_task=$(echo $new_task | sed -r 's/([tT])eh/\1he/g')
|
new_task=$(echo "$new_task" | sed -r 's/([tT])eh/\1he/g')
|
||||||
echo "Auto-corrected 'teh' --> 'the'"
|
echo "Auto-corrected 'teh' --> 'the'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo $new_task
|
echo "$new_task"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
# - Optional feedback/error.
|
# - Optional feedback/error.
|
||||||
|
|
||||||
n=0
|
n=0
|
||||||
while read modified_task
|
while read -r modified_task
|
||||||
do
|
do
|
||||||
n=$(($n + 1))
|
n=$(($n + 1))
|
||||||
done
|
done
|
||||||
|
|
|
@ -26,9 +26,9 @@ SHADOW_FILE=$(task _get rc.shadow.file)
|
||||||
task $SHADOW_COMMAND rc.detection=off rc.gc=off rc.color=off rc.hooks=off > $SHADOW_FILE 2>/dev/null
|
task $SHADOW_COMMAND rc.detection=off rc.gc=off rc.color=off rc.hooks=off > $SHADOW_FILE 2>/dev/null
|
||||||
if [[ $? != 0 ]]
|
if [[ $? != 0 ]]
|
||||||
then
|
then
|
||||||
echo Could not create $SHADOW_FILE
|
echo "Could not create $SHADOW_FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo Shadow file $SHADOW_FILE updated.
|
echo "Shadow file $SHADOW_FILE updated."
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
# Input:
|
# Input:
|
||||||
# - line of JSON for the original task
|
# - line of JSON for the original task
|
||||||
# - line of JSON for the modified task, the diff being the modification
|
# - line of JSON for the modified task, the diff being the modification
|
||||||
read original_task
|
read -r original_task
|
||||||
read modified_task
|
read -r modified_task
|
||||||
|
|
||||||
# Output:
|
# Output:
|
||||||
# - JSON, modified or unmodified.
|
# - JSON, modified or unmodified.
|
||||||
# - Optional feedback/error.
|
# - Optional feedback/error.
|
||||||
echo $modified_task
|
echo "$modified_task"
|
||||||
echo 'on-modify'
|
echo 'on-modify'
|
||||||
|
|
||||||
# Status:
|
# Status:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue