aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-10-30 00:46:06 -0300
committerEuAndreh <eu@euandre.org>2022-10-30 00:46:09 -0300
commitcae8fa432571811f712d8c068c8586ad95a87a07 (patch)
treedd38a333599f6a335dc8f04e409710a2c35efa19
parentMakefile: Exclude gen-e-list.sh from check-fixme (diff)
downloaddotfiles-cae8fa432571811f712d8c068c8586ad95a87a07.tar.gz
dotfiles-cae8fa432571811f712d8c068c8586ad95a87a07.tar.xz
bin/bins: Allow multiple instances to be ran concurrently
Use a unique temporary file for each instance, so that when more than one is active at the same time, they don't try to "mv" the "bins-tmp" file more than once.
-rwxr-xr-xbin/bins7
1 files changed, 4 insertions, 3 deletions
diff --git a/bin/bins b/bin/bins
index 710cf8a..1b28089 100755
--- a/bin/bins
+++ b/bin/bins
@@ -67,9 +67,10 @@ IFS=:
# Word-splitting is the goal:
# shellcheck disable=2086
if stest -rdq -n "$F" $PATH; then
- trap 'rm -f $F-tmp' EXIT
- stest -lxf $PATH | sort -u > "$F"-tmp
- mv "$F"-tmp "$F"
+ T="$(mkstemp)"
+ trap 'rm -f $T' EXIT
+ stest -lxf $PATH | sort -u > "$T"
+ mv "$T" "$F"
fi
cat "$F"