commit aba8275a08950bd6d260dfe6dc6c0a928bef8d85
parent fea6a3c43438fe35c9700f2f0b9b4b67ab9749a3
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Mon, 4 Nov 2019 13:15:11 -0500
conf: better link name matching?
Former-commit-id: 68fcc0d0d418f460c850005abe43d256c7bdc22f
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/scripts/conf b/scripts/conf
@@ -103,14 +103,15 @@ unlink_all() {
done
}
link_specific() {
- if ( IFS=$'\n'; echo "${mappings[*]}" ) | grep -vqFx "${i}*"; then
+ grep_result="$( ( IFS=$'\n'; echo "${!mappings[*]}" ) | grep "$1")"
+ if [ -n "$grep_result" ]; then
for f in "${!mappings[@]}"; do
- if [[ "${f}" == "${i}"* ]]; then
+ if [[ "${f%%/*}" == "$1" ]] || [ "${f}" = "$1" ]; then
do_link "${f}" "${mappings[${f}]}"
fi
done
else
- die "Error: ${i} not present in mapfile, don't know how to link."
+ die "Error: $1 not present in mapfile, don't know how to link."
fi
}
do_unlink() {
@@ -119,12 +120,13 @@ do_unlink() {
elif [ ! -L "$1" ]; then
echo "$1 is not a link, not removing."
else
- echo -n "Removing link "
+ echo -n "Removing link: "
rm -v "$1"
fi
}
unlink_specific(){
- if ( IFS=$'\n'; echo "${mappings[*]}" ) | grep -vqFx "${i}*"; then
+ grep_result="$( ( IFS=$'\n'; echo "${!mappings[*]}" ) | grep "$1")"
+ if [ -n "$grep_result" ]; then
for f in "${!mappings[@]}"; do
if [[ "${f}" == "${i}"* ]]; then
do_unlink "${mappings[${f}]}"