diff options
author | Azat Bahawi <azahi@teknik.io> | 2019-11-18 09:18:45 +0530 |
---|---|---|
committer | Anirudh <x@icyphox.sh> | 2019-11-18 09:18:45 +0530 |
commit | a820d637b23254aa6d7bd0353c31612206a82939 (patch) | |
tree | de5310fb3571c283adf15eef9c534fa96eec3d60 /pw | |
parent | a5e5d403482e8fccf7d1f1502bbf1d72962be9d2 (diff) | |
download | pw-a820d637b23254aa6d7bd0353c31612206a82939.tar.gz |
Fix shellcheck errors, make xclip copy without a newline (#2)
Diffstat (limited to 'pw')
-rwxr-xr-x | pw | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -9,7 +9,7 @@ init() { | |||
9 | mkdir -p "$PW_DIR" | 9 | mkdir -p "$PW_DIR" |
10 | echo "pw: password directory initialized at $PW_DIR" | 10 | echo "pw: password directory initialized at $PW_DIR" |
11 | else | 11 | else |
12 | echo "PW_DIR is $PW_DIR" | 12 | echo "PW_DIR is $PW_DIR" |
13 | die "$PW_DIR exists" | 13 | die "$PW_DIR exists" |
14 | fi | 14 | fi |
15 | } | 15 | } |
@@ -35,7 +35,7 @@ add() { | |||
35 | 35 | ||
36 | list() { | 36 | list() { |
37 | for f in "$PW_DIR"/*.gpg; do | 37 | for f in "$PW_DIR"/*.gpg; do |
38 | printf '%s\n' "$(basename ${f%.gpg})" | 38 | printf '%s\n' "$(basename "${f%.gpg}")" |
39 | done | 39 | done |
40 | } | 40 | } |
41 | 41 | ||
@@ -58,7 +58,7 @@ show() { | |||
58 | 58 | ||
59 | copy() { | 59 | copy() { |
60 | checkf "$PW_DIR/$1.gpg" | 60 | checkf "$PW_DIR/$1.gpg" |
61 | show "$1" | xclip -selection clipboard | 61 | show "$1" | xclip -rmlastnl -selection clipboard |
62 | echo "pw: copied $1 to clipboard" | 62 | echo "pw: copied $1 to clipboard" |
63 | } | 63 | } |
64 | 64 | ||
@@ -76,7 +76,7 @@ options: | |||
76 | -s Print password to STDOUT. | 76 | -s Print password to STDOUT. |
77 | -l List out all passwords. | 77 | -l List out all passwords. |
78 | -c Copy existing password to clipboard. | 78 | -c Copy existing password to clipboard. |
79 | -d Delete password. | 79 | -d Delete password. |
80 | -h Display this help message and exit. | 80 | -h Display this help message and exit. |
81 | 81 | ||
82 | Requires PW_KEY to be set. Optionally, set PW_DIR for custom directory location. | 82 | Requires PW_KEY to be set. Optionally, set PW_DIR for custom directory location. |
@@ -104,11 +104,12 @@ main() { | |||
104 | 104 | ||
105 | while getopts "ila:g:s:c:d:h" options | 105 | while getopts "ila:g:s:c:d:h" options |
106 | do | 106 | do |
107 | # shellcheck disable=SC2221,SC2222 | ||
107 | case "$options" in | 108 | case "$options" in |
108 | i) init ;; | 109 | i) init ;; |
109 | l) list ;; | 110 | l) list ;; |
110 | g) add "$OPTARG" ;; | 111 | g) add "$OPTARG" ;; |
111 | a) | 112 | a) |
112 | read -rsp "enter password: " pass | 113 | read -rsp "enter password: " pass |
113 | printf "\n" | 114 | printf "\n" |
114 | add "$OPTARG" "$pass" | 115 | add "$OPTARG" "$pass" |
@@ -119,7 +120,7 @@ main() { | |||
119 | *|h) usage ;; | 120 | *|h) usage ;; |
120 | esac | 121 | esac |
121 | done | 122 | done |
122 | 123 | ||
123 | shift $(( OPTIND -1 )) | 124 | shift $(( OPTIND -1 )) |
124 | } | 125 | } |
125 | 126 | ||