From aa49b475699293f77744dca810f56635f942c690 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Thu, 17 Sep 2020 19:58:51 -0700 Subject: [PATCH] updategc-util-functions.sh: parametize dupe_file temp name Allow the prefix used for the temporary file name to be specified to override the default of "packtmp-". Signed-off-by: Kyle J. McKay --- jobd/updategc-util-functions.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jobd/updategc-util-functions.sh b/jobd/updategc-util-functions.sh index 14a8be7..12d2e72 100755 --- a/jobd/updategc-util-functions.sh +++ b/jobd/updategc-util-functions.sh @@ -94,6 +94,7 @@ v_lock_file() { # and does not appear at all if the copy fails (in which case this function fails) # if the second file already exists this function fails with status 1 # if the file names are the same this function returns immediately with success +# the optional third argument specifies the temp file prefix (default is "packtmp-") dupe_file() { [ "$1" != "$2" ] || return 0 ! [ -e "$2" ] || return 1 @@ -101,7 +102,7 @@ dupe_file() { *?/?*) _tmpdir="${2%/*}";; *) _tmpdir=".";; esac - _tmpfile="$(mktemp "${_tmpdir:-.}/packtmp-XXXXXX")" || return 1 + _tmpfile="$(mktemp "${_tmpdir:-.}/${3:-packtmp-}XXXXXX")" || return 1 cp -fp "$1" "$_tmpfile" || return 1 mv -f "$_tmpfile" "$2" } -- 2.11.4.GIT