forked from libxsmm/libxsmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.mktmp.sh
executable file
·30 lines (27 loc) · 1.11 KB
/
.mktmp.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
###############################################################################
# Copyright (c) Intel Corporation - All rights reserved. #
# This file is part of the LIBXSMM library. #
# #
# For information on the license, see the LICENSE file. #
# Further information: https://github.com/hfp/libxsmm/ #
# SPDX-License-Identifier: BSD-3-Clause #
###############################################################################
# Hans Pabst (Intel Corp.)
###############################################################################
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