diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2023-01-17 11:19:49 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2023-01-17 11:19:55 -0700 |
commit | 6cf25a57debb9ed65e45c358d9c5fad43fcb75e3 (patch) | |
tree | 4a6d482294e1f5c42472ee3f526529ae90fc83be /bin/hstow | |
parent | 5a4d307df01c0be830e92dac85d563889907ba2e (diff) | |
download | dotfiles-6cf25a57debb9ed65e45c358d9c5fad43fcb75e3.tar.gz |
hstow: readlink: don't collapse runs of blanks in filename or target
Diffstat (limited to 'bin/hstow')
-rwxr-xr-x | bin/hstow | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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 |