From 5842a4ec5937d4f4b3047002b3cc298c59dd45d8 Mon Sep 17 00:00:00 2001 From: Eshan Roy Date: Tue, 19 Nov 2024 09:40:25 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20perf(improve):=20better=20?= =?UTF-8?q?error=20handling=20and=20more=20robust=20functionality,=20while?= =?UTF-8?q?=20also=20providing=20clearer=20output=20for=20the=20user?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- usr/local/bin/snigdhaos-fix-pacman-gpg-conf | 34 +++++++++++++-------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/usr/local/bin/snigdhaos-fix-pacman-gpg-conf b/usr/local/bin/snigdhaos-fix-pacman-gpg-conf index 7f02116..73c45d7 100755 --- a/usr/local/bin/snigdhaos-fix-pacman-gpg-conf +++ b/usr/local/bin/snigdhaos-fix-pacman-gpg-conf @@ -5,25 +5,33 @@ echo "Copying /etc/pacman.d/gnupg/gpg.conf" echo file_boolean=0 -function check_file() { +file="/usr/local/share/snigdhaos/gpg.conf" - file="/usr/local/share/snigdhaos/gpg.conf" - if [[ -f $file ]];then - echo $file " exists" - file_boolean=1 - else - echo $file " doesn't exist" - file_boolean=0 - fi +# Function to check if the specified file exists +check_file() { + if [[ -f "$file" ]]; then + echo "$file exists" + file_boolean=1 + else + echo "$file doesn't exist" + file_boolean=0 + fi } +# Run the file existence check check_file -if [ $file_boolean -eq 1 ] ; then - sudo cp /usr/local/share/snigdhaos/gpg.conf /etc/pacman.d/gnupg/gpg.conf - echo "/etc/pacman.d/gnupg/gpg.conf copied from local system" +# If the file exists, copy it to the appropriate location +if [ "$file_boolean" -eq 1 ]; then + echo -e "\nCopying $file to /etc/pacman.d/gnupg/gpg.conf" + if sudo cp "$file" /etc/pacman.d/gnupg/gpg.conf; then + echo "/etc/pacman.d/gnupg/gpg.conf copied from local system successfully." + else + echo "Error: Failed to copy $file to /etc/pacman.d/gnupg/gpg.conf" + exit 1 + fi fi echo echo "Task Completed!" -echo \ No newline at end of file +echo