Instead of potentially falling back to the built-in action that a custom action was intended to override, but (e.g. due to file system reorganizations) now results in a broken link. The extension functionality that is then skipped may result in undesired results, but this may not be immedately obvious to the user (if the extension is not particularly verbose), so some data corruption could occur if this remains undetected. To avoid duplicating (or somehow extracting) all the built-in actions, simply detect _any_ broken symlink; i.e. offer a superset of the required functionality. So this would also complain about a broken symlink to a non-executable custom (auxiliary) file (rarely used) if that is mistakenly passed as a custom action (unlikely). Fixes #359
33 lines
709 B
Bash
33 lines
709 B
Bash
#!/bin/bash
|
|
|
|
make_dummy_action()
|
|
{
|
|
local actionName; actionName="$(basename "${1:?}")"
|
|
cat > "$1" <<EOF
|
|
#!/bin/bash
|
|
[ "\$1" = "usage" ] && {
|
|
echo " $actionName ITEM#[, ITEM#, ...] [TERM...]"
|
|
echo " This custom action does $actionName."
|
|
echo ""
|
|
exit
|
|
}
|
|
echo "custom action $actionName$2"
|
|
EOF
|
|
chmod +x "$1"
|
|
}
|
|
|
|
make_action()
|
|
{
|
|
unset TODO_ACTIONS_DIR
|
|
[ -d .todo.actions.d ] || mkdir .todo.actions.d
|
|
[ -z "$1" ] || make_dummy_action ".todo.actions.d/$1"
|
|
}
|
|
|
|
make_action_in_folder()
|
|
{
|
|
unset TODO_ACTIONS_DIR
|
|
[ -d .todo.actions.d ] || mkdir .todo.actions.d
|
|
mkdir ".todo.actions.d/$1"
|
|
[ -z "$1" ] || make_dummy_action ".todo.actions.d/$1/$1" "in folder $1"
|
|
}
|