search directory only

master
Dominik Schrempf 6 years ago
parent ca8432153f
commit 8395cf42d5
  1. 35
      syncthing-resolve-conflicts

@ -9,6 +9,7 @@ declare -r myver='1.0.2'
diffprog=${DIFFPROG:-'vim -d'}
USE_COLOR='y'
declare -i USE_FIND=0
declare DIRECTORY=""
declare -a ignored
declare -a nontext
@ -101,23 +102,51 @@ version() {
cmd() {
if (( USE_FIND )); then
find ~/ -name '*sync-conflict*' -print0
if [[ -z $DIRECTORY ]]
then
# echo "find ~/ -name '*sync-conflict*' -print0"
find ~/ -name '*sync-conflict*' -print0
else
# echo "find $DIRECTORY -name '*sync-conflict*' -print0" >&2
find $DIRECTORY -name '*sync-conflict*' -print0
fi
else
case "$(uname -s)" in
Darwin)
locate -0 sync-conflict;;
locate_cmd=(locate -0);;
*)
locate -0 -e -b sync-conflict;;
locate_cmd=(locate -0 -e);;
esac
if [[ -z $DIRECTORY ]]
then
locate_opt=(-b)
glob="sync-conflict"
else
locate_opt=(-r)
glob="^${DIRECTORY}.*sync-conflict.*"
fi
# echo "${locate_cmd[@]}" "${locate_opt[@]}" "$glob" >&2
"${locate_cmd[@]}" "${locate_opt[@]}" "$glob"
fi
}
check_dir() {
if [[ ! -d $1 ]]
then
echo "Not a directory: $1."
exit 1
fi
realpath "$1"
}
while [[ -n "$1" ]]; do
case "$1" in
-h|--help)
usage; exit 0;;
-v|-V|--version)
version; exit 0;;
-d|--directory)
DIRECTORY=$(check_dir "$2"); shift;;
-f|--find)
USE_FIND=1;;
-o|--output)

Loading…
Cancel
Save