mirror of
https://github.com/lhns/steam-frame-nix.git
synced 2026-10-06 04:04:16 +02:00
Cleanup: rewrites count as actions and keep the --quiet header to one
c_write was fed through a pipe, so it ran in a subshell: its action count and the printed header were lost, which printed "nothing to clean up" after a rewrite, and a second header with --quiet. It takes the content as an argument now.
This commit is contained in:
1 parent
daf7c70ed3
commit
32bd719284
1 file changed
+7
-9
+7
-9
@@ -471,13 +471,11 @@ c_rmdir() { # dir: removed if empty (after the planned removals)
|
|||||||
rmdir -- "$1" && CLEAN_GONE[$1]=1 && c_done "removed empty directory $1"
|
rmdir -- "$1" && CLEAN_GONE[$1]=1 && c_done "removed empty directory $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
c_write() { # path why: replace the contents with stdin (same inode and mode)
|
# Not fed through a pipe: a pipe's subshell would lose CLEAN_ACTIONS and the
|
||||||
local tmp
|
# --quiet header state.
|
||||||
if (( CLEAN_DRY )); then cat >/dev/null; c_do "rewrite $1 ($2)" || true; return 0; fi
|
c_write() { # path why content: replace the contents (same inode and mode)
|
||||||
c_do "rewrite $1 ($2)"
|
c_do "rewrite $1 ($2)" || return 0
|
||||||
tmp="$(mktemp "$1.sfn-XXXXXX")"
|
printf '%s\n' "$3" >"$1"
|
||||||
cat >"$tmp" && cat "$tmp" >"$1"
|
|
||||||
rm -f -- "$tmp"
|
|
||||||
c_done "rewrote $1 ($2)"
|
c_done "rewrote $1 ($2)"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -753,7 +751,7 @@ clean_firefox() { # all
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
left="$(grep -vF "$pats" "$prof/prefs.js" || true)"
|
left="$(grep -vF "$pats" "$prof/prefs.js" || true)"
|
||||||
printf '%s\n' "$left" | c_write "$prof/prefs.js" "values of the $kind: ${keys//$'\n'/ }"
|
c_write "$prof/prefs.js" "values of the $kind: ${keys//$'\n'/ }" "$left"
|
||||||
fi
|
fi
|
||||||
c_rm "$u" "$kind"
|
c_rm "$u" "$kind"
|
||||||
c_rmdir "$prof"
|
c_rmdir "$prof"
|
||||||
@@ -814,7 +812,7 @@ clean_jellyfin() {
|
|||||||
if [[ -z $(tr -d '[:space:]' <<<"$out") ]]; then
|
if [[ -z $(tr -d '[:space:]' <<<"$out") ]]; then
|
||||||
c_rm "$JF_OVERRIDE" "Flatpak override with only the hwdec shim entries"
|
c_rm "$JF_OVERRIDE" "Flatpak override with only the hwdec shim entries"
|
||||||
else
|
else
|
||||||
printf '%s\n' "$out" | c_write "$JF_OVERRIDE" "hwdec shim entries"
|
c_write "$JF_OVERRIDE" "hwdec shim entries" "$out"
|
||||||
warn "$JF_OVERRIDE keeps entries of its own: $(grep -v '^\[' <<<"$out" | grep . | tr '\n' ' ')"
|
warn "$JF_OVERRIDE keeps entries of its own: $(grep -v '^\[' <<<"$out" | grep . | tr '\n' ' ')"
|
||||||
fi
|
fi
|
||||||
elif (( rc == 3 )); then
|
elif (( rc == 3 )); then
|
||||||
|
|||||||
Reference in new issue
Block a user