BarbUk / dotfiles

My dotfiles, used on archlinux, osx and debian
31 stars 3 forks source link

{cursor} feature in snippy is broken #2

Closed olivierlemoal closed 4 years ago

olivierlemoal commented 4 years ago

Thanks for this nice little script. It looks like the {cursor} feature in template is broken because of set -o errexit on https://github.com/BarbUk/dotfiles/blob/master/bin/snippy#L133

It works fine with

move_cursor() {    
    local key=$1
    local count=$2
    local keys="End "
    if [[ $count -gt 0 ]]; then
        until [  "$count" -eq 0 ]; do
            keys+="${key} "
            let "count--"
        done
        # shellcheck disable=SC2086
        xdotool key --delay 0.1 $keys
    fi
}
BarbUk commented 4 years ago

Good catch. It's because ((expr)) return an exit code when the result is 0:

$ count=2
$ ((count-=1))
$ echo $?
0
$ ((count-=1))
$ echo $?
1