Skip to content

Commit

Permalink
helpers: fix non-atomic cache write
Browse files Browse the repository at this point in the history
This was causing some values to be repeated more than once when using
multiple tmux windows at the same time, for example for the RAM
percentage in ram_percentage.sh.

GitHub: fixes tmux-plugins#62
  • Loading branch information
pacien committed Jan 5, 2023
1 parent 9eb3dba commit f609bed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,10 @@ put_cache_val() {
val="${*:2}"
tmpdir="$(get_tmp_dir)"
[ ! -d "$tmpdir" ] && mkdir -p "$tmpdir" && chmod 0700 "$tmpdir"
get_time >"$tmpdir/$key"
echo -n "$val" >>"$tmpdir/$key"
(
get_time
echo -n "$val"
) >"$tmpdir/$key"
echo -n "$val"
}

Expand Down

0 comments on commit f609bed

Please sign in to comment.