From 038aecad4c6dab82f9aaec055a34df958e134d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Wed, 2 Mar 2022 18:55:29 +0100 Subject: [PATCH] little refactorings --- libexec/kiwi-cron/create_schedule | 2 +- libexec/kiwi-cron/print_crontab | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/libexec/kiwi-cron/create_schedule b/libexec/kiwi-cron/create_schedule index 34ed88c..5a09075 100755 --- a/libexec/kiwi-cron/create_schedule +++ b/libexec/kiwi-cron/create_schedule @@ -4,7 +4,7 @@ cs_every="${1:-1}" cs_units="${2}" cs_command="${3}" -if [ "${cs_every}" -eq 1 ]; then +if [ "${cs_every}" = "1" ]; then cs_every="" else cs_every="/${cs_every}" diff --git a/libexec/kiwi-cron/print_crontab b/libexec/kiwi-cron/print_crontab index a2c6a29..0647be6 100755 --- a/libexec/kiwi-cron/print_crontab +++ b/libexec/kiwi-cron/print_crontab @@ -1,28 +1,16 @@ #!/bin/sh -print_cron_schedule () { - pcs_minute="${1}" - pcs_hour="${2}" - pcs_day="${3}" - pcs_month="${4}" - pcs_weekday="${5}" - pcs_command="${6}" - - printf '%-8s%-8s%-8s%-8s%-8s%s\n' \ - "${pcs_minute}" "${pcs_hour}" "${pcs_day}" "${pcs_month}" "${pcs_weekday}" "${pcs_command}" -} - # header echo '# crontab generated by kiwi-cron' echo '# generation time: '"$(date)" echo '#' # short documentation line -print_cron_schedule \ +printf '%-8s%-8s%-8s%-8s%-8s%s\n' \ "# min" "hour" "day" "month" "weekday" "command" # schedules -while read -r pc_min pc_hour pc_day pc_month pc_weekday pc_command; do - print_cron_schedule \ - "${pc_min}" "${pc_hour}" "${pc_day}" "${pc_month}" "${pc_weekday}" "${pc_command}" +while read -r pc_minute pc_hour pc_day pc_month pc_weekday pc_command; do + printf '%-8s%-8s%-8s%-8s%-8s%s\n' \ + "${pc_minute}" "${pc_hour}" "${pc_day}" "${pc_month}" "${pc_weekday}" "${pc_command}" done