From e69c6f040eb65a24cba60a6e5245ecf13a8914f5 Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Wed, 27 Nov 2024 20:26:28 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=89=20feat(=5Fvar):=20better=20readabi?= =?UTF-8?q?lity=20and=20to=20separate=20the=20date=20format=20from=20the?= =?UTF-8?q?=20rest=20of=20the=20message.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snigdhaos-libs/snigdhaos.shlib | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) mode change 100644 => 100755 snigdhaos-libs/snigdhaos.shlib diff --git a/snigdhaos-libs/snigdhaos.shlib b/snigdhaos-libs/snigdhaos.shlib old mode 100644 new mode 100755 index ae24913d..1fa20413 --- a/snigdhaos-libs/snigdhaos.shlib +++ b/snigdhaos-libs/snigdhaos.shlib @@ -1,5 +1,15 @@ #!/bin/bash -snigdhaoslib_add_update_notice(){ + +snigdhaoslib_add_update_notice() { + # Ensure the directory exists mkdir -p /var/lib/snigdhaos/tmp - echo "$(date +%F) ${1// / }" >>/var/lib/snigdhaos/tmp/update_notices -} \ No newline at end of file + + # Get the current date + current_date=$(date +%F) + + # Replace multiple spaces with a single space in the input string + message="${1//[[:space:]]+/ }" + + # Append the message to the file with the current date + echo "$current_date $message" >> /var/lib/snigdhaos/tmp/update_notices +}