summaryrefslogtreecommitdiff
path: root/bin/hstow
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-01-08 14:50:04 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-01-08 14:53:07 -0700
commit7ccdb2a6019cfa0c0c81597d992c71ec3e8c05cf (patch)
treee8ac8288d0f49fc681e2e75c38db58234b072744 /bin/hstow
parente8c5d47e66bf2be77004ba3a56af8b6fabc9dd8f (diff)
downloaddotfiles-7ccdb2a6019cfa0c0c81597d992c71ec3e8c05cf.tar.gz
hstow: when unstowing, don't recurse into directories we don't own
Diffstat (limited to 'bin/hstow')
-rwxr-xr-xbin/hstow5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/hstow b/bin/hstow
index e54587e1..00cf5817 100755
--- a/bin/hstow
+++ b/bin/hstow
@@ -53,7 +53,7 @@ read_globs_file () {
}
dir_contents () {
- ( cd "$1"; find . ! -name . ! -name "$cchars" 2>/dev/null )
+ ( cd "$1"; find . ! -name . ! -name "$cchars" -print -prune )
}
fail () {
@@ -140,7 +140,8 @@ unstow () {
dir_pat=".$(echo $DIR | cut -c$(echo $HOME | wc -m | tr -d ' ')-)/"
dirs_pat="$(echo "^($dir_pat$ignores)" | sed -e 's#\.#\\.#g')"
- for file in $(find . -type l ! -name . ! -name "$cchars" 2>/dev/null \
+ for file in $(find . ! \( -user "$(id -un)" -o -group "$(id -gn)" \) \
+ -prune -o -type l ! -name . ! -name "$cchars" -print \
| grep -Ev "$dirs_pat"); do
if readlink "$file" | grep -Eq '^(\.\./)*\.STOW/'"$NAME/"; then
rm "$file"