Commit b694990
Eric Bower
·
2026-08-14 23:43:14 -0400 EDT
parent 27dd607
refactor: check-in recipients file
2 files changed,
+31,
-6
M
bin/pa
M
bin/pa
+13,
-1
1@@ -208,6 +208,7 @@ usage() {
2
3 env vars:
4 data directory: export PA_DIR=~/.local/share/pa
5+ recipients file: export PA_RECIPIENTS=$PA_DIR/passwords/recipients
6 password length: export PA_LENGTH=50
7 password pattern: export PA_PATTERN=A-Za-z0-9_-
8 disable tracking: export PA_NOGIT=
9@@ -228,7 +229,18 @@ main() {
10 die "PA_DIR must be an absolute path (got '$PA_DIR')"
11
12 identities_file=$PA_DIR/identities
13- recipients_file=$PA_DIR/recipients
14+
15+ if [ -n "$PA_RECIPIENTS" ]; then
16+ recipients_file=$PA_RECIPIENTS
17+ elif [ -f "$PA_DIR/passwords/recipients" ]; then
18+ recipients_file=$PA_DIR/passwords/recipients
19+ elif [ -f "$PA_DIR/passwords/.recipients" ]; then
20+ recipients_file=$PA_DIR/passwords/.recipients
21+ elif [ -f "$PA_DIR/recipients" ]; then
22+ recipients_file=$PA_DIR/recipients
23+ else
24+ recipients_file=$PA_DIR/passwords/recipients
25+ fi
26
27 mkdir -p "$PA_DIR/passwords" ||
28 die "couldn't create pa directories"
+18,
-5
1@@ -18,7 +18,24 @@ umask 077
2
3 : "${PA_DIR:=${XDG_DATA_HOME:-$HOME/.local/share}/pa}"
4 : "${PA_IDENTITIES:=$PA_DIR/identities}"
5-: "${PA_RECIPIENTS:=$PA_DIR/recipients}"
6+
7+passdir=$PA_DIR/passwords
8+[ -d "$passdir" ] ||
9+ die "password directory '$passdir' doesn't exist"
10+
11+if [ -n "$PA_RECIPIENTS" ]; then
12+ recipients_file=$PA_RECIPIENTS
13+elif [ -f "$passdir/recipients" ]; then
14+ recipients_file=$passdir/recipients
15+elif [ -f "$passdir/.recipients" ]; then
16+ recipients_file=$passdir/.recipients
17+elif [ -f "$PA_DIR/recipients" ]; then
18+ recipients_file=$PA_DIR/recipients
19+else
20+ recipients_file=$passdir/recipients
21+fi
22+
23+PA_RECIPIENTS=$recipients_file
24
25 [ -f "$PA_IDENTITIES" ] ||
26 die "identities file '$PA_IDENTITIES' doesn't exist"
27@@ -26,10 +43,6 @@ umask 077
28 [ -f "$PA_RECIPIENTS" ] ||
29 die "recipients file '$PA_RECIPIENTS' doesn't exist"
30
31-passdir=$PA_DIR/passwords
32-[ -d "$passdir" ] ||
33- die "password directory '$passdir' doesn't exist"
34-
35 cd "$passdir" ||
36 die "couldn't change to password directory"
37