diff options
| author | Matěj Cepl <mcepl@cepl.eu> | 2025-01-05 18:55:14 +0100 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-01-06 07:38:01 -0700 |
| commit | 824a7d19ae5bdc8eb6b3d61a591dc26d33ab3a38 (patch) | |
| tree | f2e3f324011a852c04247e97caaf2110b7260611 /vis-clipboard | |
| parent | 75892aad7939b40354be7ea71bd55c651956b27c (diff) | |
| download | vis-824a7d19ae5bdc8eb6b3d61a591dc26d33ab3a38.tar.gz vis-824a7d19ae5bdc8eb6b3d61a591dc26d33ab3a38.tar.xz | |
scripts: fix shellcheck warnings and make scripts more uniform
Diffstat (limited to 'vis-clipboard')
| -rwxr-xr-x | vis-clipboard | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/vis-clipboard b/vis-clipboard index ad0408d..0f9e90b 100755 --- a/vis-clipboard +++ b/vis-clipboard @@ -1,6 +1,7 @@ #!/bin/sh - # Copyright (C) 2016 Richard Burke, ISC licensed +# shellcheck disable=SC2317 +set -e vc_fatal() { echo "$@" >&2 @@ -8,7 +9,13 @@ vc_fatal() { } vc_usage() { - vc_fatal "$(basename "$0") [--selection sel] [--usable|--copy|--paste]" + vc_fatal "Usage: $(basename "$0") [--selection sel] [--usable|--copy|--paste] + +Copy/paste clipboard interface with support on all provided platforms. + +Available selections: clipboard, primary + +Example: $(basename "$0") --copy --selection primary" } vc_determine_command() { @@ -153,8 +160,13 @@ while [ $# -gt 0 ]; do --usable) fn=vc_usable;; --copy) fn=vc_copy;; --paste) fn=vc_paste;; - --selection) shift; sel="$1";; - *) ;; + --selection) + shift + if [ "$1" != "clipboard" ] && [ "$1" != "primary" ]; then + vc_fatal "Invalid selection: $1\nValid options are 'clipboard' or 'primary'" + fi + sel="$1";; + *) vc_usage;; esac shift done |
