Robustness: Check for broken symlinks to custom actions and complain

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
This commit is contained in:
Ingo Karkat
2021-09-16 22:15:00 +02:00
parent 1185ab1d5e
commit e1c1c328a2
3 changed files with 55 additions and 3 deletions

View File

@@ -1038,7 +1038,13 @@ listWordsWithSigil()
hasCustomAction()
{
[ -d "${1:?}" ] && [ -x "${1:?}/${2:?}" ]
[ -d "${1:?}" ] || return 1
[ -x "$1/${2:?}" ] && return 0
if [ -h "$1/$2" ] && [ ! -e "$1/$2" ]
then
dieWithHelp "$2" "Fatal Error: Broken link to custom action: '$1/$2'"
fi
return 1
}
export -f cleaninput getPrefix getTodo getNewtodo shellquote filtercommand _list listWordsWithSigil getPadding _format die