-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path.mktmp.sh
More file actions
executable file
·25 lines (23 loc) · 865 Bytes
/
Copy path.mktmp.sh
File metadata and controls
executable file
·25 lines (23 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
###############################################################################
# Copyright (c) Intel Corporation - All rights reserved. #
# #
# For information on the license, see the LICENSE file. #
# SPDX-License-Identifier: BSD-3-Clause #
###############################################################################
MKTEMP=$(command -v mktemp)
MV=$(command -v mv)
if [ "${MKTEMP}" ] && [ "${MV}" ]; then
TEMPLATE=${1/XXXXXX/}.XXXXXX
TMPFILE=$(${MKTEMP} "${TEMPLATE}")
EXTFILE=${TMPFILE: -6}
NEWFILE=${1/XXXXXX/${EXTFILE}}
if [ "$1" != "${NEWFILE}" ]; then
${MV} "${TMPFILE}" "${NEWFILE}"
echo "${NEWFILE}"
else
echo "${TMPFILE}"
fi
else
touch "$1"
fi