summaryrefslogtreecommitdiff
path: root/bin/hstow
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-01-19 10:13:25 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-01-19 11:02:14 -0700
commit99765c58281cf79d9b27576c80483b868d1d73c5 (patch)
tree2cebf1cd26b0d3d105741ad5ecc27c90252c64c4 /bin/hstow
parent8ab0e26154e513a9d1f65757be56bc36037b3621 (diff)
downloaddotfiles-99765c58281cf79d9b27576c80483b868d1d73c5.tar.gz
hstow: readlinks: check link targets for control chars
Diffstat (limited to 'bin/hstow')
-rwxr-xr-xbin/hstow14
1 files changed, 11 insertions, 3 deletions
diff --git a/bin/hstow b/bin/hstow
index 3fce0a72..7aba04de 100755
--- a/bin/hstow
+++ b/bin/hstow
@@ -53,11 +53,19 @@ fi
# Here we unconditionally bypass readlink(1), for speed.
# The long regexp is because only BREs have backreferences in POSIX.
readlinks () {
- local restc=$1 assume="${2:-false}" first= rest=
+ local restc=$1 assume="${2:-false}" first= rest= ls=
while read -r first rest; do
if $assume || [ -h "$first" ]; then
- [ -n "$rest" ] && rest="$rest$tab"
- rest="$rest$(ls -ld "$first")"
+ ls="$(ls -ld "$first")"
+ case "$ls" in
+ $cchars)
+ printf \
+ 'hstow: skipping %s due to control chars in link target\n' \
+ "$first" >&2
+ continue
+ ;;
+ esac
+ [ -n "$rest" ] && rest="$rest$tab$ls" || rest=$ls
fi
printf '%s\t%s\n' "$first" "$rest"
done | sed 's/^\([^\t]\{1,\}\)\t\('\