Tolerate plugin filenames containing special characters

We may only allow characters allowed in shell function names.
This commit is contained in:
Lars Kruse 2020-02-09 02:18:17 +01:00
parent b039f7c1c8
commit 4b484f6f99
1 changed files with 2 additions and 1 deletions

View File

@ -89,7 +89,8 @@ for PLUG in $PLUGINS; do
plugindir_)
for MYPLUGIN in $(if [ -d "$PLUGIN_DIRECTORY" ]; then find -L "$PLUGIN_DIRECTORY" -type f -name "$PLUGINPATTERN"; fi); do
if [ -f "$MYPLUGIN" ] && [ -x "$MYPLUGIN" ]; then
MYPLUGINNAME=$(basename "$MYPLUGIN")
# generate a name suitable for shell function names
MYPLUGINNAME=$(basename "$MYPLUGIN" | sed 's/[^0-9a-zA-Z_]/_/g')
# detect and avoid name collision
if echo "$RES" | grep -qwF "$MYPLUGINNAME"; then
MYPLUGINNAME="plugindir_$MYPLUGINNAME"