aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAoi Koizumi <novaburst@kalli.st>2022-01-30 00:23:38 -0300
committerAoi Koizumi <novaburst@kalli.st>2022-01-30 00:23:38 -0300
commit720529b3f573cfe6afcfa3fe65a4a5630148c1cd (patch)
treec97e81ff8de61e2fabe308bdce1112ee8193fe4f
parent46b1c4e1be64d3fa4be3597d87d469b8423b043e (diff)
downloadayu-720529b3f573cfe6afcfa3fe65a4a5630148c1cd.tar.gz
shell(c)heck is a mess, and updated manual page
Signed-off-by: Aoi Koizumi <novaburst@kalli.st>
-rwxr-xr-xayu46
-rw-r--r--ayu.mdoc17
2 files changed, 38 insertions, 25 deletions
diff --git a/ayu b/ayu
index b6b22c6..b728fdd 100755
--- a/ayu
+++ b/ayu
@@ -19,31 +19,31 @@ public_key="${public_key:-${ayu_dir}/public_key}"
EDITOR=${EDITOR:-vi}
# Run some tests
-test -d $ayu_dir || mkdir -p $ayu_dir
-test -d $ayu_store || mkdir -p $ayu_store
+test -d "$ayu_dir" || mkdir -p "$ayu_dir"
+test -d "$ayu_store" || mkdir -p "$ayu_store"
-test -f $private_key || printf "$0: Generate your own age(1) key with age-keygen(1) and place it as a $private_key. \n"
-test -f $public_key || printf "$0: Public key needs to be placed on $public_key (Hint: it's the visible output of age-keygen(1)) \n"
+test -f "$private_key" || printf "Generate your own age(1) key with age-keygen(1) and place it as %s \n" "$private_key" >&2
+test -f "$public_key" || printf "Public key needs to be placed on %s \n" "$public_key" >&2
# Switch directory to the password store, otherwise bail out.
-cd $ayu_store || exit 1
+cd "$ayu_store" || exit 1
# Copy an entry to the clipboard
copy() {
- view "$2" | sed 1q | $clipboard
+ view "$2" | sed 1q | "$clipboard"
}
# Edit an entry if it exists
edit() {
- age --decrypt --identity=$private_key --output=${1%%.age} ${1%%.age}.age
- ${EDITOR} ${1%%.age}
- age --encrypt -R $public_key --output=${1%%.age}.age ${1%%.age}
- rm ${1%%.age}
+ age --decrypt --identity="$private_key" --output="${1%%.age}" "${1%%.age}.age"
+ ${EDITOR} "${1%%.age}"
+ age --encrypt -R "$public_key" --output="${1%%.age}.age" "${1%%.age}"
+ rm "${1%%.age}"
}
# List contents of the store
list() {
- tree $ayu_store
+ tree "$ayu_store"
}
# Create a new entry
@@ -54,15 +54,15 @@ new() {
${EDITOR} "$tmpfile"
mkdir -p "$(dirname "$1")"
- age --encrypt -R $public_key -o $tmpfile.age $tmpfile
+ age --encrypt -R "$public_key" -o "$tmpfile.age" "$tmpfile"
- mv $tmpfile.age "${1%%.age}".age
- rm $tmpfile
+ mv "$tmpfile.age" "${1%%.age}".age
+ rm "$tmpfile"
}
# Remove
remove() {
- rm -f ${1}${2}.age
+ rm -f "${1}${2}.age"
}
# Remove recursively
@@ -71,13 +71,13 @@ remove_recursive() {
}
# Print usage
usage() {
- printf "$0 [ -c | -e | -l | -n | -r | -R | -v ] <entry> \n"
+ printf "Usage: [ -c | -e | -l | -n | -r | -R | -v ] <entry> \n"
}
# View an entry, otherwise list the contents of the directory specified.
view() {
if [ -f "${1%%.age}".age ];then
- age --decrypt --identity=$private_key "${1%%.age}".age
+ age --decrypt --identity="$private_key" "${1%%.age}".age
elif [ -d "${1:-.}" ];then
tree "${1:-.}"
else
@@ -87,13 +87,13 @@ view() {
}
case $1 in
- -c) copy $2 ;;
- -e) edit $2 ;;
+ -c) copy "$2" ;;
+ -e) edit "$2" ;;
-l) list ;;
- -n) new $2 ;;
- -r) remove $2 $3 ;;
- -R) remove_recursive $2 ;;
+ -n) new "$2" ;;
+ -r) remove "$2" "$3" ;;
+ -R) remove_recursive "$2" ;;
-h) usage ;;
- -v) view $2 ;;
+ -v) view "$2" ;;
*) usage ;;
esac
diff --git a/ayu.mdoc b/ayu.mdoc
index ac4022c..03767a5 100644
--- a/ayu.mdoc
+++ b/ayu.mdoc
@@ -1,4 +1,4 @@
-.Dd January 28, 2022
+.Dd January 30, 2022
.Dt ayu 1
.Os
.Sh NAME
@@ -59,7 +59,20 @@ The private key should be placed on
and the public key to
.Em ~/.ayu/public_key
for the utility to work
-.Pp
+.Sh SEE ALSO
+.Xr age 1
+.Xr age-keygen 1
+.Xr less 1
+.Xr sh 1
+.Xr tree 1
+.Xr vi 1
+.Xr xclip 1
+.Rs
+.%A Rob Pike
+.%T "UNIX Style, or cat -v Considered Harmful"
+.%J "USENIX Summer Conference Proceedings"
+.%D 1983
+.Re
.Sh AUTHORS
.An Aoi Koizumi
.Mt novaburst@kalli.st