diff options
| author | Federico Angelilli <code@fedang.net> | 2024-01-01 19:01:17 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2024-01-01 19:01:17 +0100 |
| commit | 925e8b36fa9ba8a9c9d0b2ae0b4807fd3bf5c3f3 (patch) | |
| tree | c8c5f0fbe91fdf15cbd63519936f100f7b4c0b69 /crypt.sh | |
| parent | af93c4f747a02766d62a0f971ccc6f4d97a8a520 (diff) | |
Fix check_file function
Diffstat (limited to 'crypt.sh')
| -rwxr-xr-x | crypt.sh | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -226,7 +226,7 @@ entries_show+=( "none" ) entries_edit+=( "none" ) entries_color+=( "white,bold" ) -# Directory entry FIXME +# Directory entry entries_ext+=( "" ) entries_name+=( "" ) entries_insert+=( "none" ) @@ -291,13 +291,12 @@ find_entry() { } check_file() { - # Expects a non-directory path local path="${1#$CRYPT_PATH/}" [[ -f "$CRYPT_PATH/$path.gpg" ]] && echo "$path" && return local matches=() for ((i = 3; i < ${#entries_name[@]}; i++)); do - readarray -t -O ${#matches[@]} matches < <(find "$CRYPT_PATH/" -path '*/.git' -prune -o -path "$CRYPT_PATH/${path%/}${entries_ext[$i]}.gpg" -print) + readarray -t -O ${#matches[@]} matches < <(find "$CRYPT_PATH/" -path '*/.git' -prune -o -path "$CRYPT_PATH/${path%/}.${entries_ext[$i]}.gpg" -print) done case ${#matches[@]} in @@ -309,7 +308,6 @@ check_file() { confirm_file() { local entry=$(find_entry "${1%.gpg}.gpg") ans="" - [[ ($entry -eq 0 && ${#entries_ext[@]} -eq 3) || $entry -eq 1 ]] && echo "$1" && return while true; do @@ -317,7 +315,6 @@ confirm_file() { echo "${entries_ext[$i]}) $(_color ${entries_color[$i]})${entries_name[$i]}$(_color reset)" >&2 done read -r -p "Select one of the valid entries: " ans - for ((i = 3; i < ${#entries_name[@]}; i++)); do if [[ "$ans" == "${entries_ext[$i]}" || "$ans" == "${entries_name[$i]}" ]]; then echo "${1%.}.$ans" |
