Update config.sh

This commit is contained in:
Santiago Lo Coco 2024-04-07 10:50:23 +02:00
parent 7ad41a8423
commit 1bc59e8704
1 changed files with 0 additions and 13 deletions

View File

@ -9,28 +9,15 @@ find_config_file() {
fi fi
local config_files=($(find -L "$XDG_CONFIG_HOME" \( -name "$program*" -o -name ".$program*" \) -type f)) local config_files=($(find -L "$XDG_CONFIG_HOME" \( -name "$program*" -o -name ".$program*" \) -type f))
#local config_files=($(find -L "$XDG_CONFIG_HOME" -name "$program*" -type f))
if [ ${#config_files[@]} -gt 0 ]; then if [ ${#config_files[@]} -gt 0 ]; then
local min_subfolder_count=10 local min_subfolder_count=10
for file in "${config_files[@]}"; do for file in "${config_files[@]}"; do
subfolder_count=$(echo "$file" | awk -F/ '{print NF-2}') subfolder_count=$(echo "$file" | awk -F/ '{print NF-2}')
#if [ -z "$config_file" ] || [ "$subfolder_count" -lt "$min_subfolder_count" ]; then
if [ -z "$config_file" ] || { [ "$subfolder_count" -lt "$min_subfolder_count" ] || { [ "$subfolder_count" -eq "$min_subfolder_count" ] && [ "$(basename "$file")" == "$program.${file##*.}" ]; }; }; then if [ -z "$config_file" ] || { [ "$subfolder_count" -lt "$min_subfolder_count" ] || { [ "$subfolder_count" -eq "$min_subfolder_count" ] && [ "$(basename "$file")" == "$program.${file##*.}" ]; }; }; then
min_subfolder_count="$subfolder_count" min_subfolder_count="$subfolder_count"
config_file="$file" config_file="$file"
fi fi
done done
#exact_match_files=()
#for file in "${config_files[@]}"; do
# if [ "$(basename "$file")" == "$program.${file##*.}" ]; then
# exact_match_files+=("$file")
# fi
#done
#if [ ${#exact_match_files[@]} -gt 0 ]; then
# config_file="${exact_match_files[0]}"
#fi
fi fi
if [ -z "$config_file" ]; then if [ -z "$config_file" ]; then