Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
DLR-AMR
GitHub Repository: DLR-AMR/t8code
Path: blob/main/scripts/check_if_file_indented.sh
900 views
1
#! /bin/bash
2
3
# This file is part of t8code.
4
# t8code is a C library to manage a collection (a forest) of multiple
5
# connected adaptive space-trees of general element classes in parallel.
6
#
7
# Copyright (C) 2025 the developers
8
#
9
# t8code is free software; you can redistribute it and/or modify
10
# it under the terms of the GNU General Public License as published by
11
# the Free Software Foundation; either version 2 of the License, or
12
# (at your option) any later version.
13
#
14
# t8code is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
18
#
19
# You should have received a copy of the GNU General Public License
20
# along with t8code; if not, write to the Free Software Foundation, Inc.,
21
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
23
#
24
# This script checks if a given file is correctly indented according to the t8indent.sh script.
25
#
26
27
GIT_REPO_PATH=$(git rev-parse --show-toplevel)
28
29
INDENT_SCRIPT=${GIT_REPO_PATH}/scripts/t8indent.sh
30
31
usage="USAGE:$0 [FILE_TO_CHECK]\n\nWill check if [FILE_TO_CHECK] is correctly indentend according to the script t8indent.sh."
32
33
# Check if first argument given
34
if [ ${1-x} = x ]
35
then
36
echo ERROR: Need to provide a file as first argument.
37
echo $usage
38
exit 1
39
fi
40
41
# Check if first argument is a file and store it in variable
42
if [ -f "$1" ]
43
then
44
file="$1"
45
else
46
# Try from folder above.
47
if [ -f "../$1" ]
48
then
49
file="../$1"
50
else
51
echo "ERROR: Non existing file: $1"
52
echo $usage
53
exit 1
54
fi
55
fi
56
57
#
58
# Check if the file is indented
59
#
60
$INDENT_SCRIPT NO_CHANGE $file
61
status=$?
62
if [ $status != 0 ]
63
then
64
echo $file is not indented.
65
echo
66
fi
67
exit $status
68
69
70