From 10c837d58d77491aa362ff51ffb7f1c1959bae8d Mon Sep 17 00:00:00 2001 From: Luca Pizzamiglio <57148+pizzamig@users.noreply.github.com> Date: Fri, 16 Sep 2022 16:35:52 +0200 Subject: [PATCH] The current sed script delete everything (#225) * The current sed script delete everything This easy fix, while not super robust, seems a first good patch * Clean only when there is more then one status * Sync Changelog --- CHANGELOG.md | 3 +++ share/pot/set-status.sh | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8500590..8d8828f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed +- set-status: fix a bug that delete the status (#224) + ## [0.15.0] 2022-09-11 ### Added - mount-out: new command to remove or unmount a previously mount-in folder or fs diff --git a/share/pot/set-status.sh b/share/pot/set-status.sh index 580fe3c..f7dfcf8 100644 --- a/share/pot/set-status.sh +++ b/share/pot/set-status.sh @@ -43,9 +43,11 @@ _set_status() echo "pot.status=$_new_status" >> "$_status_file" # remove first (and outdated) occurrence of pot.status - ${SED} -i '' -n -e ":a" \ - -e '/^pot\.status=/{n;bc' -e ':c' -e 'p;n;bc' -e '}' \ - -e "p;n;ba" "$_status_file" + if [ "$(grep -c "^pot\.status=" "$_status_file")" -gt 1 ]; then + ${SED} -i '' -n -e ":a" \ + -e '/^pot\.status=/{n;bc' -e ':c' -e 'p;n;bc' -e '}' \ + -e "p;n;ba" "$_status_file" + fi } pot-set-status()