summaryrefslogtreecommitdiff
path: root/bin/hstow
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2023-01-17 11:19:49 -0700
committerSean Whitton <spwhitton@spwhitton.name>2023-01-17 11:19:55 -0700
commit6cf25a57debb9ed65e45c358d9c5fad43fcb75e3 (patch)
tree4a6d482294e1f5c42472ee3f526529ae90fc83be /bin/hstow
parent5a4d307df01c0be830e92dac85d563889907ba2e (diff)
downloaddotfiles-6cf25a57debb9ed65e45c358d9c5fad43fcb75e3.tar.gz
hstow: readlink: don't collapse runs of blanks in filename or target
Diffstat (limited to 'bin/hstow')
-rwxr-xr-xbin/hstow9
1 files changed, 7 insertions, 2 deletions
diff --git a/bin/hstow b/bin/hstow
index ff5ae181..21cbeca6 100755
--- a/bin/hstow
+++ b/bin/hstow
@@ -39,8 +39,13 @@ cchars="$(printf '*[\001-\037\177]*')"
if ! command -v readlink >/dev/null; then
readlink () {
# Safe parse of ls(1) output given its POSIX specification.
- ls -ld "$1" | tr -s ' ' \
- | cut -d' ' -f9- | cut -c$((4 + $(echo "$1" | wc -m)))-
+ #
+ # We want the ninth field onwards in awk's sense --
+ # i.e. collapsing multiple runs of blanks between the first nine
+ # fields -- but we mustn't collapse blanks from there onwards.
+ ls -ld "$1" \
+ | sed -E 's/^[[:blank:]]*([^[:blank:]]+[[:blank:]]+){8}.{'$((
+ 3 + $(echo "$1" | wc -m)))'}//'
}
fi