clipmenu

Simple clipboard management using dmenu
git clone https://git.sinitax.com/cdown/clipmenu
Log | Files | Refs | README | LICENSE | sfeed.txt

commit 2acece7dce6f6f2dd1e722c40b932f9358abd8e1
parent 683f57484fb32f8e810b59e3a96a8d361d255e95
Author: Chris Down <chris@chrisdown.name>
Date:   Fri, 17 Feb 2017 11:55:48 -0500

Put $major_version in cache_dir to avoid upgrade incompatibility

Diffstat:
Mclipmenu | 4+++-
Mclipmenud | 3++-
Mtests/test-clipmenu | 20+++++++++++---------
Mtests/test-perf | 4+++-
4 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/clipmenu b/clipmenu @@ -1,8 +1,10 @@ #!/bin/bash +major_version=3 + shopt -s nullglob -cache_dir=/tmp/clipmenu.$USER +cache_dir=/tmp/clipmenu.$major_version.$USER cache_file=$cache_dir/line_cache # It's okay to hardcode `-l 8` here as a sensible default without checking diff --git a/clipmenud b/clipmenud @@ -1,6 +1,7 @@ #!/bin/bash -cache_dir=/tmp/clipmenu.$USER/ +major_version=3 +cache_dir=/tmp/clipmenu.$major_version.$USER/ cache_file=$cache_dir/line_cache version=2.0.0 version_file=$cache_dir/version diff --git a/tests/test-clipmenu b/tests/test-clipmenu @@ -3,7 +3,8 @@ set -e set -o pipefail -dir=/tmp/clipmenu.$USER +major_version=3 +dir=/tmp/clipmenu.$major_version.$USER cache_file=$dir/line_cache if [[ $0 == /* ]]; then @@ -59,18 +60,19 @@ EOF output=$(/tmp/clipmenu --foo bar 2>&1) -printf '%s\n' "$output" > /tmp/qq +temp=$(mktemp) +printf '%s\n' "$output" > "$temp" # Arguments are transparently passed to dmenu -grep -Fxq 'dmenu args: -l 8 --foo bar' <<< "$output" +grep -Fxq 'dmenu args: -l 8 --foo bar' "$temp" # Output from cache file should get to dmenu, reversed -grep -Fxq 'dmenu line 1 stdin: Selected text 2. (2 lines)' <<< "$output" -grep -Fxq 'dmenu line 2 stdin: Selected text. (2 lines)' <<< "$output" +grep -Fxq 'dmenu line 1 stdin: Selected text 2. (2 lines)' "$temp" +grep -Fxq 'dmenu line 2 stdin: Selected text. (2 lines)' "$temp" # xsel should copy both to clipboard *and* primary -grep -Fxq 'xsel args: --logfile /dev/null -i --clipboard' <<< "$output" -grep -Fxq 'xsel args: --logfile /dev/null -i --primary' <<< "$output" +grep -Fxq 'xsel args: --logfile /dev/null -i --clipboard' "$temp" +grep -Fxq 'xsel args: --logfile /dev/null -i --primary' "$temp" -grep -Fxq 'xsel line 1 stdin: Selected text.' <<< "$output" -grep -Fxq "xsel line 2 stdin: Yes, it's selected text." <<< "$output" +grep -Fxq 'xsel line 1 stdin: Selected text.' "$temp" +grep -Fxq "xsel line 2 stdin: Yes, it's selected text." "$temp" diff --git a/tests/test-perf b/tests/test-perf @@ -1,10 +1,12 @@ #!/bin/bash +major_version=3 + msg() { printf '>>> %s\n' "$@" >&2 } -dir=/tmp/clipmenu.$USER +dir=/tmp/clipmenu.$major_version.$USER cache_file=$dir/line_cache log=$(mktemp)