diff options
| author | Matěj Cepl <mcepl@cepl.eu> | 2022-07-17 19:24:54 +0200 |
|---|---|---|
| committer | Felix Van der Jeugt <felix.vanderjeugt@posteo.net> | 2022-08-15 13:25:08 +0200 |
| commit | a719fe1adc977bcc51f007876b5cf84a977f6111 (patch) | |
| tree | 1ad9c47c5c2b1d7f17d9205d64c645d0045ce331 /vis-clipboard | |
| parent | cad2b9a9d74c59ac05524f4e747d72ea7a62796c (diff) | |
| download | vis-a719fe1adc977bcc51f007876b5cf84a977f6111.tar.gz vis-a719fe1adc977bcc51f007876b5cf84a977f6111.tar.xz | |
vis-clipboard: clean up bashisms and make shellcheck happy.
Diffstat (limited to 'vis-clipboard')
| -rwxr-xr-x | vis-clipboard | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/vis-clipboard b/vis-clipboard index 8397ee2..4efefbb 100755 --- a/vis-clipboard +++ b/vis-clipboard @@ -8,13 +8,13 @@ vc_fatal() { } vc_usage() { - vc_fatal "`basename $0` [--selection sel] [--usable|--copy|--paste]" + vc_fatal "$(basename "$0") [--selection sel] [--usable|--copy|--paste]" } vc_determine_command() { if [ -n "$WAYLAND_DISPLAY" ]; then for c in wl-copy wl-paste; do - if type "$c" >/dev/null 2>&1; then + if command -v "$c" >/dev/null 2>&1; then echo "wlclipboard" return 0 fi @@ -23,7 +23,7 @@ vc_determine_command() { if [ -n "$DISPLAY" ]; then for c in xclip xsel; do - if type "$c" >/dev/null 2>&1; then + if command -v "$c" >/dev/null 2>&1; then echo "$c" return 0 fi @@ -34,7 +34,7 @@ vc_determine_command() { vc_fatal "clipboard primary selection is not supported on your platform" fi - if type pbcopy >/dev/null 2>&1; then + if command -v pbcopy >/dev/null 2>&1; then echo 'mac' return 0 fi @@ -56,25 +56,27 @@ vc_usable() { } vc_copy() { - COPY_CMD="`vc_determine_command 2>/dev/null`" + COPY_CMD="$(vc_determine_command 2>/dev/null)" + # shellcheck disable=SC2181 if [ $? -ne 0 ] || [ -z "$COPY_CMD" ]; then vc_fatal 'System clipboard not supported' fi - vc_${COPY_CMD}_copy + "vc_${COPY_CMD}_copy" exit $? } vc_paste() { - PASTE_CMD="`vc_determine_command 2>/dev/null`" + PASTE_CMD="$(vc_determine_command 2>/dev/null)" + # shellcheck disable=SC2181 if [ $? -ne 0 ] || [ -z "$PASTE_CMD" ]; then vc_fatal 'System clipboard not supported' fi - vc_${PASTE_CMD}_paste + "vc_${PASTE_CMD}_paste" exit $? } |
