fix globbing problem in _find function
parent
22b3c0cc36
commit
28bce82117
|
@ -1 +1,2 @@
|
||||||
*/archive/*
|
*/archive/*
|
||||||
|
/ssh/config/_config
|
||||||
|
|
|
@ -58,7 +58,7 @@ build_file "/etc/ssh/ssh_config" $OUTPUT
|
||||||
for CDIR in "${CDIRS[@]}"
|
for CDIR in "${CDIRS[@]}"
|
||||||
do
|
do
|
||||||
# FILES=$(find -n '*.cfg' -d 0 $CDIR)
|
# FILES=$(find -n '*.cfg' -d 0 $CDIR)
|
||||||
for f in $(find -n '*.cfg' -p 'archive off' -d 0 $CDIR) ;
|
for f in $(_find -n '*.cfg' -p 'archive off' -d 0 $CDIR) ;
|
||||||
do
|
do
|
||||||
# echo "Processing $f";
|
# echo "Processing $f";
|
||||||
[[ $f ]] && build_file "$f" $OUTPUT
|
[[ $f ]] && build_file "$f" $OUTPUT
|
||||||
|
|
|
@ -71,7 +71,7 @@ case "$OPTION" in
|
||||||
n)
|
n)
|
||||||
# NAMES=("$OPTARG")
|
# NAMES=("$OPTARG")
|
||||||
IFS=',' read -r -a NAMES <<< "${OPTARG}"
|
IFS=',' read -r -a NAMES <<< "${OPTARG}"
|
||||||
# echo INCLUDING ONLY THESE FILE NAMES ${NAMES[*]}
|
# NAMES=$OPTARG
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
DEPTH=$OPTARG
|
DEPTH=$OPTARG
|
||||||
|
@ -128,6 +128,8 @@ fi
|
||||||
# echo paths ${PATHS[@]} >&2
|
# echo paths ${PATHS[@]} >&2
|
||||||
# echo exclude names ${ENAMES[@]} >&2
|
# echo exclude names ${ENAMES[@]} >&2
|
||||||
|
|
||||||
|
set -o noglob
|
||||||
|
|
||||||
if [[ ${PATHS[0]} ]]; then
|
if [[ ${PATHS[0]} ]]; then
|
||||||
for path in ${PATHS[@]}; do
|
for path in ${PATHS[@]}; do
|
||||||
# echo excluding $path
|
# echo excluding $path
|
||||||
|
@ -137,22 +139,32 @@ fi
|
||||||
|
|
||||||
if [[ ${ENAMES[0]} ]]; then
|
if [[ ${ENAMES[0]} ]]; then
|
||||||
for name in ${ENAMES[@]}; do
|
for name in ${ENAMES[@]}; do
|
||||||
# echo excluding name $name
|
debug excluding name "$name"
|
||||||
FIND+=$(echo ' ! -name "'${name}'"')
|
FIND+=$(echo ' ! -name '$name'')
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
debug "INCLUDING ONLY THESE FILE NAMES ${NAMES[*]}"
|
||||||
if [[ ${NAMES[0]} ]]; then
|
if [[ ${NAMES[0]} ]]; then
|
||||||
for name in ${NAMES[@]}; do
|
for name in "${NAMES[@]}"; do
|
||||||
# echo only finding $name
|
debug only finding $name
|
||||||
FIND+=$(echo " -name ${name}")
|
FIND+=$(echo " -name '${name}'")
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# if [[ $NAMES ]]; then
|
||||||
|
# debug names for find command $NAMES
|
||||||
|
# for name in $NAMES; do
|
||||||
|
# debug "xxonly finding '$name'"
|
||||||
|
# FIND+=$(set -o noglob;echo " -name '${name}'")
|
||||||
|
# done
|
||||||
|
# fi
|
||||||
|
|
||||||
|
|
||||||
# echo
|
# echo
|
||||||
# echo find dir: $DIR >&2
|
# echo find dir: $DIR >&2
|
||||||
debug "find command: $FIND"
|
debug "find command: $FIND"
|
||||||
|
set +o noglob
|
||||||
local FILES
|
local FILES
|
||||||
FILES=$(eval $FIND | sort)
|
FILES=$(eval $FIND | sort)
|
||||||
[[ $FILES ]] && echo $FILES
|
[[ $FILES ]] && echo $FILES
|
||||||
|
|
Reference in New Issue