From 2889dbb40b5891309861d79d20e16288d7fa12a9 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Sun, 13 Nov 2022 09:38:29 -0700 Subject: hstow: use correct option to wc(1) for counting characters not bytes --- bin/hstow | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin/hstow') diff --git a/bin/hstow b/bin/hstow index d151504b..f05f0aaf 100755 --- a/bin/hstow +++ b/bin/hstow @@ -40,7 +40,7 @@ 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 -c)))- + | cut -d' ' -f9- | cut -c$((4 + $(echo "$1" | wc -m)))- } fi @@ -131,7 +131,7 @@ stow () { unstow () { cd "$HOME" - dir_pat="^.$(echo $DIR | cut -c$(echo $HOME | wc -c)-)/" + dir_pat="^.$(echo $DIR | cut -c$(echo $HOME | wc -m)-)/" for file in $(find . -type l ! -name . ! -name "$cchars" \ | grep -v "$dir_pat"); do if readlink "$file" | grep -Eq '^(\.\./)*\.STOW/'"$NAME/"; then @@ -158,7 +158,7 @@ unstow () { [ $# = 2 ] || usage [ -d "$2" ] || fail "$2 is not an existing directory" DIR="$(cd $2; pwd)" -[ "$(echo $DIR | cut -c-$(($(echo $HOME | wc -c) - 1)))" = "$HOME" ] \ +[ "$(echo $DIR | cut -c-$(($(echo $HOME | wc -m) - 1)))" = "$HOME" ] \ || fail "$DIR is not below $HOME" NAME="$(echo $DIR | tr / _)" -- cgit v1.2.3