From 00fc8ea318ebe48915b5b152ee55a948952b132c Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Thu, 20 Jul 2023 21:54:09 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(flatpak-sync)=20Fail=20add/remove?= =?UTF-8?q?=20if=20app=20id=20is=20commented=20out?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Handling commented out apps would perhaps be interesting to add in the future. But at this point I think the the people using this script either want to go fully declarative and not use the add/remove commands at all or do not want to edit the apps list file themselves and therefore will not have and comments in them. Refs: #1 --- flatpak-sync/flatpak-sync.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/flatpak-sync/flatpak-sync.sh b/flatpak-sync/flatpak-sync.sh index 0db2e90..a674300 100755 --- a/flatpak-sync/flatpak-sync.sh +++ b/flatpak-sync/flatpak-sync.sh @@ -46,11 +46,16 @@ function add() { exit 1 fi - if grep "$appId" "$APPS_LIST_PATH"; then - echo "App already in apps list. Run with sync command to install." + if grep -q "# $appId" "$APPS_LIST_PATH"; then + echo "App already in apps list but commented out. Manual fix of the app list file necessary." exit 2 fi + if grep -q "$appId" "$APPS_LIST_PATH"; then + echo "App already in apps list. Run with sync command to install." + exit 3 + fi + local appsListFile appsListFile="$(realpath "$APPS_LIST_PATH")" echo "$appId" >> "$appsListFile" @@ -64,7 +69,12 @@ function remove() { exit 1 fi - if ! grep "$appId" "$APPS_LIST_PATH"; then + if grep -q "# $appId" "$APPS_LIST_PATH"; then + echo "App already in apps list but commented out. No remove possible." + exit 2 + fi + + if ! grep -q "$appId" "$APPS_LIST_PATH"; then echo "App not in apps list." exit 2 fi