aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-11-25 20:21:35 +1300
committerTom Ryder <tom@sanctum.geek.nz>2016-11-25 20:21:35 +1300
commitb6df9ed3c173f47271f447b1d0b79ae7f90683af (patch)
treecb87f300a9d097b7a4f668c5eb99b7e4d7ec28e4 /bin
parentAdd finc(1df) (diff)
downloaddotfiles-b6df9ed3c173f47271f447b1d0b79ae7f90683af.tar.gz
dotfiles-b6df9ed3c173f47271f447b1d0b79ae7f90683af.zip
Handle find(1) path metachars
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cf6
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/cf b/bin/cf
index 362e4eba..5e2f42b9 100755
--- a/bin/cf
+++ b/bin/cf
@@ -14,9 +14,13 @@ for dir in "${@:-.}" ; do
continue
fi
+ # Make an escaped form of the directory to handle cases where the directory
+ # name actually has find(1) pattern metacharacters in it
+ dirx=$(printf %s "$dir" | sed 's/\([*?\[\]]\)/\\\1/g')
+
# Count the files
count=$(
- find "$dir" ! -path "$dir" -prune -exec printf %.sx {} + |
+ find "$dir" ! -path "$dirx" -prune -exec printf %.sx {} + |
wc -c
)