pacdiff: rework search type handling, add --find option
Change cmd tests to if (( USE_FIND ))... as it is cleaner. All search cmds have an option and a variable initialized to zero. The active option should be set to 1. Add a switch to exclude multiple search options. set the default when all are equal to zero. Signed-off-by: Jonathan Frazier <eyeswide@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
b1b9ca01f0
commit
15eea825e6
1 changed files with 22 additions and 11 deletions
|
@ -23,9 +23,9 @@ declare -r myver='@PACKAGE_VERSION@'
|
||||||
|
|
||||||
diffprog=${DIFFPROG:-vimdiff}
|
diffprog=${DIFFPROG:-vimdiff}
|
||||||
diffsearchpath=${DIFFSEARCHPATH:-/etc}
|
diffsearchpath=${DIFFSEARCHPATH:-/etc}
|
||||||
locate=0
|
|
||||||
USE_COLOR='y'
|
USE_COLOR='y'
|
||||||
declare -a oldsaves
|
declare -a oldsaves
|
||||||
|
declare -i USE_FIND=0 USE_LOCATE=0
|
||||||
|
|
||||||
m4_include(../scripts/library/output_format.sh)
|
m4_include(../scripts/library/output_format.sh)
|
||||||
|
|
||||||
|
@ -33,10 +33,13 @@ usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
$myname is a simple pacnew/pacorig/pacsave updater.
|
$myname is a simple pacnew/pacorig/pacsave updater.
|
||||||
|
|
||||||
Usage: $myname [-l]
|
Usage: $myname [-l | -f] [--nocolor]
|
||||||
|
|
||||||
Options:
|
Search Options: select one, default: find
|
||||||
-l/--locate scan using locate (default: find)
|
-l/--locate scan using locate
|
||||||
|
-f/--find scan using find
|
||||||
|
|
||||||
|
General Options:
|
||||||
--nocolor remove colors from output
|
--nocolor remove colors from output
|
||||||
|
|
||||||
Enviroment Variables:
|
Enviroment Variables:
|
||||||
|
@ -56,9 +59,9 @@ version() {
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd() {
|
cmd() {
|
||||||
if [ $locate -eq 1 ]; then
|
if (( USE_LOCATE )); then
|
||||||
locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave '*.pacsave.[0-9]*'
|
locate -0 -e -b \*.pacnew \*.pacorig \*.pacsave '*.pacsave.[0-9]*'
|
||||||
else
|
elif (( USE_FIND )); then
|
||||||
find $diffsearchpath \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave -o -name '*.pacsave.[0-9]*' \) -print0
|
find $diffsearchpath \( -name \*.pacnew -o -name \*.pacorig -o -name \*.pacsave -o -name '*.pacsave.[0-9]*' \) -print0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -66,7 +69,9 @@ cmd() {
|
||||||
while [[ -n "$1" ]]; do
|
while [[ -n "$1" ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-l|--locate)
|
-l|--locate)
|
||||||
locate=1;;
|
USE_LOCATE=1;;
|
||||||
|
-f|--find)
|
||||||
|
USE_FIND=1;;
|
||||||
--nocolor)
|
--nocolor)
|
||||||
USE_COLOR='n' ;;
|
USE_COLOR='n' ;;
|
||||||
-V|--version)
|
-V|--version)
|
||||||
|
@ -81,6 +86,12 @@ done
|
||||||
|
|
||||||
m4_include(../scripts/library/term_colors.sh)
|
m4_include(../scripts/library/term_colors.sh)
|
||||||
|
|
||||||
|
case $(( USE_FIND + USE_LOCATE )) in
|
||||||
|
0) USE_FIND=1;; # set the default search option
|
||||||
|
[^1]) error "Only one search option may be used at a time"
|
||||||
|
usage; exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
# see http://mywiki.wooledge.org/BashFAQ/020
|
# see http://mywiki.wooledge.org/BashFAQ/020
|
||||||
while IFS= read -u 3 -r -d '' pacfile; do
|
while IFS= read -u 3 -r -d '' pacfile; do
|
||||||
file="${pacfile%.pac*}"
|
file="${pacfile%.pac*}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue