From 84292c1271427f500b8070cc78512233ac9f273e Mon Sep 17 00:00:00 2001 From: Niels Hofmans Date: Mon, 13 Nov 2023 07:18:41 +0100 Subject: [PATCH 1/3] feat: support @ crontab notation fixes https://github.com/hazcod/maclaunch/issues/21 --- maclaunch.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/maclaunch.sh b/maclaunch.sh index 6cc3d4a..a49a639 100755 --- a/maclaunch.sh +++ b/maclaunch.sh @@ -60,9 +60,20 @@ function getKernelExtensions { } function getCronjobs { - crontab -l 2>/dev/null | grep -v '^#' | cut -d ' ' -f 6 + while IFS= read -r cron; do + if echo "$cron" | cut -d ' ' -f 1 | grep -q '@'; then + # @reboot notation + echo "$cron" | cut -d ' ' -f 2 + else + # * * * * * notation + echo "$cron" | cut -d ' ' -f 6 + fi + done <<<"$(crontab -l 2>/dev/null | grep -v '^#' | grep -vE '^\n')" } +getCronjobs +exit 1 + function listCronJobs { local filter="$1" From e7af4c5024998e59239c7d133a71139c95696250 Mon Sep 17 00:00:00 2001 From: Niels Hofmans Date: Mon, 13 Nov 2023 07:19:53 +0100 Subject: [PATCH 2/3] chore: remove debug command --- maclaunch.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/maclaunch.sh b/maclaunch.sh index a49a639..e0dd4c8 100755 --- a/maclaunch.sh +++ b/maclaunch.sh @@ -71,9 +71,6 @@ function getCronjobs { done <<<"$(crontab -l 2>/dev/null | grep -v '^#' | grep -vE '^\n')" } -getCronjobs -exit 1 - function listCronJobs { local filter="$1" From 933a5094df799f76fc093a61930125d1ed202992 Mon Sep 17 00:00:00 2001 From: Niels Hofmans Date: Mon, 13 Nov 2023 07:25:51 +0100 Subject: [PATCH 3/3] fix: ignore empty lines on cron lines --- maclaunch.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/maclaunch.sh b/maclaunch.sh index e0dd4c8..6c4d314 100755 --- a/maclaunch.sh +++ b/maclaunch.sh @@ -61,6 +61,10 @@ function getKernelExtensions { function getCronjobs { while IFS= read -r cron; do + if [ -z "$cron" ]; then + continue + fi + if echo "$cron" | cut -d ' ' -f 1 | grep -q '@'; then # @reboot notation echo "$cron" | cut -d ' ' -f 2 @@ -84,7 +88,7 @@ function listCronJobs { echo -e " Type : cronjob" echo -e " User : $(whoami)" echo -e " Launch: ${ORANGE}enabled${NC}" - echo " File : n/a" + echo " File : ${name}" done }