From 720529b3f573cfe6afcfa3fe65a4a5630148c1cd Mon Sep 17 00:00:00 2001 From: Aoi Koizumi Date: Sun, 30 Jan 2022 00:23:38 -0300 Subject: shell(c)heck is a mess, and updated manual page Signed-off-by: Aoi Koizumi --- ayu | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'ayu') 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 ] \n" + printf "Usage: [ -c | -e | -l | -n | -r | -R | -v ] \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 -- cgit 1.4.1-2-gfad0