From eb8206f4eed177f5b27334e671d05cfdc77ec820 Mon Sep 17 00:00:00 2001 From: Pierre Kisters <1524059+lhns@users.noreply.github.com> Date: Thu, 1 Oct 2026 04:07:47 +0200 Subject: [PATCH] Cleanup: a prefs.js that can't be read is left as is, not emptied grep's read error (status 2) was swallowed with || true, so the profile's prefs.js could be rewritten with nothing. Now it warns and keeps both prefs.js and user.js for the next run. --- install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 27bcc4d..904e280 100755 --- a/install.sh +++ b/install.sh @@ -716,7 +716,7 @@ ff_keys() { sed -n 's/^[[:space:]]*user_pref(\("[^"]*"\),.*/\1/p' "$1" 2>/dev/nu ff_in_use() { [[ -n $(find /proc/[0-9]*/fd -lname "$1/.parentlock" -print -quit 2>/dev/null) ]]; } clean_firefox() { # all - local all=$1 prof name u t kind keys pats left + local all=$1 prof name u t kind keys pats left rc [[ -d $FF_DIR ]] || return 0 for prof in "$FF_DIR"/*/; do prof=${prof%/}; name=${prof##*/}; u=$prof/user.js @@ -750,7 +750,8 @@ clean_firefox() { # all c_defer "$u: Firefox is using profile $name; close it and run this again" continue fi - left="$(grep -vF "$pats" "$prof/prefs.js" || true)" + rc=0; left="$(grep -vF "$pats" "$prof/prefs.js")" || rc=$? + if (( rc > 1 )); then warn "could not read $prof/prefs.js; left as is"; continue; fi c_write "$prof/prefs.js" "values of the $kind: ${keys//$'\n'/ }" "$left" fi c_rm "$u" "$kind"