clipfsck (801B)
1 #!/usr/bin/env bash 2 3 : "${CM_DIR="${XDG_RUNTIME_DIR-"${TMPDIR-/tmp}"}"}" 4 5 major_version=6 6 7 shopt -s nullglob 8 9 cache_dir=$CM_DIR/clipmenu.$major_version.$USER 10 cache_file=$cache_dir/line_cache 11 12 declare -A cksums 13 14 while IFS= read -r line; do 15 cksum=$(cksum <<< "$line") 16 cksums["$cksum"]="$line" 17 18 # Are all cache entries represented by a file? 19 full_file=$cache_dir/$cksum 20 if ! [[ -f $full_file ]]; then 21 printf 'cache entry without file: %s -> %s\n' "$line" "$full_file" >&2 22 fi 23 done < <(cut -d' ' -f2- < "$cache_file") 24 25 # Are all files represented by a cache entry? 26 for file in "$cache_dir"/[012346789]*; do 27 cksum=${file##*/} 28 line=${cksums["$cksum"]-_missing_} 29 if [[ $line == _missing_ ]]; then 30 printf 'file without cache entry: %s\n' "$file" 31 fi 32 done