aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnirudh Oppiliappan <x@icyphox.sh>2019-12-23 10:35:22 +0530
committerAnirudh Oppiliappan <x@icyphox.sh>2019-12-23 10:35:22 +0530
commit2b60c621abcaa7425260ca5e7393b9dd964f315c (patch)
tree0307fc262a1141cfb8f910a25763208ea0e5fb0d
parent5ce74504501fe36ffd4dbb8cb22f156c4dfc8699 (diff)
downloadpw-2b60c621abcaa7425260ca5e7393b9dd964f315c.tar.gz
Improve consistency; use printfs instead of echos
Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
-rwxr-xr-xpw20
1 files changed, 10 insertions, 10 deletions
diff --git a/pw b/pw
index ace6134..b3f1dc9 100755
--- a/pw
+++ b/pw
@@ -7,9 +7,9 @@
7init() { 7init() {
8 if [[ ! -e "$PW_DIR" ]]; then 8 if [[ ! -e "$PW_DIR" ]]; then
9 mkdir -p "$PW_DIR" 9 mkdir -p "$PW_DIR"
10 echo "pw: password directory initialized at $PW_DIR" 10 printf "pw: password directory initialized at %s" "$PW_DIR"
11 else 11 else
12 echo "PW_DIR is $PW_DIR" 12 printf "PW_DIR is %s" "$PW_DIR"
13 die "$PW_DIR exists" 13 die "$PW_DIR exists"
14 fi 14 fi
15} 15}
@@ -24,13 +24,13 @@ add() {
24 else 24 else
25 # uses default length of 25 chars, unless PW_LEN is set 25 # uses default length of 25 chars, unless PW_LEN is set
26 pass="$(pwgen "${PW_LEN:-25}" 1 -s)" 26 pass="$(pwgen "${PW_LEN:-25}" 1 -s)"
27 echo "pw: generated password for $1" 27 printf "pw: generated password for %s" "$1"
28 fi 28 fi
29 if [[ ! -f "$PW_DIR/$1.gpg" ]]; then 29 if [[ ! -f "$PW_DIR/$1.gpg" ]]; then
30 echo "$pass" | gpg2 -er "$PW_KEY" -o "$PW_DIR/$1.gpg" 30 printf "%s" "$pass" | gpg2 -er "$PW_KEY" -o "$PW_DIR/$1.gpg"
31 echo "pw: $PW_DIR/$1.gpg created" 31 printf "pw: %s/%s.gpg created" "$PW_DIR" "$1"
32 else 32 else
33 die "the file $PW_DIR/$1.gpg exists" 33 die "the file %s/%s.gpg exists" "$PW_DIR" "$1"
34 fi 34 fi
35} 35}
36 36
@@ -46,7 +46,7 @@ del() {
46 printf "\n" 46 printf "\n"
47 [[ "$REPLY" == [yY] ]] && { 47 [[ "$REPLY" == [yY] ]] && {
48 rm -f "$PW_DIR/$1.gpg" 48 rm -f "$PW_DIR/$1.gpg"
49 echo "pw: deleted $1" 49 printf "pw: deleted %s" "$1"
50 } 50 }
51} 51}
52 52
@@ -60,7 +60,7 @@ show() {
60copy() { 60copy() {
61 checkf "$PW_DIR/$1.gpg" 61 checkf "$PW_DIR/$1.gpg"
62 show "$1" | xclip -rmlastnl -selection clipboard 62 show "$1" | xclip -rmlastnl -selection clipboard
63 echo "pw: copied $1 to clipboard" 63 printf "pw: copied %s to clipboard" "$1"
64} 64}
65 65
66usage() { 66usage() {
@@ -84,7 +84,7 @@ Requires PW_KEY to be set. Optionally, set PW_DIR for custom directory location.
84Set PW_LEN to an integer of your choice, to override the default password length of 25. 84Set PW_LEN to an integer of your choice, to override the default password length of 25.
85" 85"
86 86
87 echo "$usage" 87 printf "%s" "$usage"
88 exit 1 88 exit 1
89} 89}
90 90
@@ -94,7 +94,7 @@ checkf() {
94} 94}
95 95
96die() { 96die() {
97 printf "error: %s\n" "$1" 97 printf "error: %s\n" "$1" >&2
98 exit 1 98 exit 1
99} 99}
100 100