forked from libxsmm/libxsmm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.flock.sh
executable file
·29 lines (26 loc) · 1.04 KB
/
.flock.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
#!/usr/bin/env sh
###############################################################################
# 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/libxsmm/libxsmm/ #
# SPDX-License-Identifier: BSD-3-Clause #
###############################################################################
# Hans Pabst (Intel Corp.)
###############################################################################
FLOCK=$(command -v flock)
if [ -d "$1" ]; then
ABSDIR=$(cd "$1" && pwd -P)
elif [ -f "$1" ]; then
ABSDIR=$(cd "$(dirname "$1")" && pwd -P)
else
ABSDIR=$(cd "$(dirname "$0")" && pwd -P)
fi
shift
cd "${ABSDIR}" || true
if [ "${FLOCK}" ]; then
${FLOCK} "${ABSDIR}" -c "$@"
else
eval "$*"
fi