diff options
author | EuAndreh <eu@euandre.org> | 2022-10-30 00:46:06 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2022-10-30 00:46:09 -0300 |
commit | cae8fa432571811f712d8c068c8586ad95a87a07 (patch) | |
tree | dd38a333599f6a335dc8f04e409710a2c35efa19 | |
parent | Makefile: Exclude gen-e-list.sh from check-fixme (diff) | |
download | dotfiles-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-x | bin/bins | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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" |