From f9bec273e29c564fb579fd7397c1472b89f97bb9 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sun, 25 Feb 2024 19:57:20 -0500 Subject: [PATCH] minor code style improvements * Use emacs auto-indentation & document cli command to auto-indent for non-emacs users. Automatic indent allows for easier and consistent contribution. * Add explicit true for empty case conditions. This makes it clear it wasn't mistakenly empty and emacs indents it more consistently. * Set emacs config for indent level to help emacs users. --- README.md | 5 +++++ kaya | 8 ++++++-- kaya-client | 12 ++++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f4a6ceb..f1b38b1 100644 --- a/README.md +++ b/README.md @@ -122,3 +122,8 @@ new backups, and to read archived data. If you'd like to contribute to Kaya, feel free to open an issue or pull request, or email me with a link to your branch. +Kaya's bash files use emacs standard indentation. To indent FILE, run + +``` +emacs FILE --batch --eval '(progn (indent-region (point-min) (point-max)) (save-buffer))' +``` diff --git a/kaya b/kaya index 6d85d3c..ebd7510 100755 --- a/kaya +++ b/kaya @@ -89,6 +89,7 @@ get-params() { case $action in backup) # currently the only option is to backup + true ;; *) echo "kaya: error: invalid action argument: $action" >&2 @@ -138,8 +139,8 @@ start-backup() { # make the backup over a forwarded port cat << EOF | ssh -o PasswordAuthentication=no -R "${remote_port}:localhost:${local_port}" \ - "${remote_user}@${hostname}" kaya-client \ - "${remote_port@Q}" "${hostname@Q}" "${backup_options[@]@Q}" \ + "${remote_user}@${hostname}" kaya-client \ + "${remote_port@Q}" "${hostname@Q}" "${backup_options[@]@Q}" \ | tee "${log_dump}" | { grep -v "KAYA_SUCCESSFUL_BACKUP_MESSAGE" ||:; } ${kaya_protocol_version} ${password} @@ -215,3 +216,6 @@ main() { main "$@" +# Local Variables: +# sh-basic-offset: 4 +# End: diff --git a/kaya-client b/kaya-client index 2c53308..4f9c28c 100755 --- a/kaya-client +++ b/kaya-client @@ -30,6 +30,7 @@ read -r kaya_protocol_version case $kaya_protocol_version in 1|2) + true ;; *) echo "kaya-client: error: mismatched protocol version with kaya" >&2 @@ -57,15 +58,22 @@ ret=0 case $ret in 0) # success + true ;; 3) # restic warning, such as file randomly disappearing during backup # consider it success + true ;; *) - echo "kaya-client: command exit code $ret: ${cmd[*]}" >&2 - exit $ret + echo "kaya-client: command exit code $ret: ${cmd[*]}" >&2 + exit $ret + ;; esac # needed in case ssh dies on the backup server, and exits with 0 (patched in OpenSSH version 8.8) if [[ $kaya_protocol_version -ge 2 ]] ; then echo "KAYA_SUCCESSFUL_BACKUP_MESSAGE" ; fi + +# Local Variables: +# sh-basic-offset: 4 +# End: -- 2.25.1