Improved check for components that are already enabled

This commit is contained in:
Nils Winkler
2017-05-10 11:12:07 +02:00
parent 56d0f56714
commit b1481038d8
2 changed files with 17 additions and 8 deletions

View File

@@ -328,14 +328,11 @@ _enable-thing ()
plugin=$(basename $plugin)
# Check for existence of the file using a wildcard, since we don't know which priority might have been used when enabling it.
for f in $BASH_IT/$subdirectory/enabled/*$BASH_IT_LOAD_PRIORITY_SEPARATOR$plugin; do
if [ -e "$f" ] ; then
printf '%s\n' "$file_entity is already enabled."
return
fi
break
done
typeset enabled_plugin=$(command ls $BASH_IT/$subdirectory/enabled/{[0-9]*$BASH_IT_LOAD_PRIORITY_SEPARATOR$plugin,$plugin} 2>/dev/null | head -1)
if [ ! -z "$enabled_plugin" ] ; then
printf '%s\n' "$file_entity is already enabled."
return
fi
mkdir -p $BASH_IT/$subdirectory/enabled