From cae8fa432571811f712d8c068c8586ad95a87a07 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sun, 30 Oct 2022 00:46:06 -0300 Subject: 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. --- bin/bins | 7 ++++--- 1 file 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" -- cgit v1.2.3