Check extraneous arguments on each subcommand

This commit is contained in:
Peter Cai 2022-10-10 15:36:37 -04:00
parent cf670956d8
commit fe28c7e3df
1 changed files with 4 additions and 0 deletions

View File

@ -31,6 +31,7 @@ gocrypt_die() {
}
gocrypt_init() {
[ $# -eq 0 ] || gocrypt_die "Unexpected argument"
gocrypt_sys_check
if [ -d "$gocrypt_dir" ] || [ -f "$gocrypt_dir" ]; then
gocrypt_die "gocrypt plugin already initialized for your password store"
@ -59,6 +60,7 @@ gocrypt_init() {
}
gocrypt_open() {
[ $# -eq 0 ] || gocrypt_die "Unexpected argument"
gocrypt_close_check
mkdir -p "$gocrypt_dec_dir"
@ -66,6 +68,7 @@ gocrypt_open() {
}
gocrypt_close() {
[ $# -eq 0 ] || gocrypt_die "Unexpected argument"
gocrypt_open_check
fusermount -u "$gocrypt_dec_dir" || fusermount -u -z "$gocrypt_dec_dir"
}
@ -80,6 +83,7 @@ gocrypt_delegate() {
}
gocrypt_crypt() {
[ $# -eq 1 ] || gocrypt_die "Unexpected argument"
gocrypt_open_check
[ ! -f "$1.gpg" ] && gocrypt_die "Not found: $1"
cmd_show "$1" | EDITOR=tee gocrypt_delegate edit "$1"