-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneeds_copyright.sh
executable file
·50 lines (43 loc) · 1.66 KB
/
needs_copyright.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
#################################################################
# #
# Copyright (c) 2020-2023 YottaDB LLC and/or its subsidiaries. #
# All rights reserved. #
# #
# This source code contains the intellectual property #
# of its copyright holder(s), and is made available #
# under a license. If you do not know the terms of #
# the license, please stop and do not read further. #
# #
#################################################################
# Determines whether a file should need a copyright by its name
# Returns 0 if it needs a copyright and 1 otherwise.
# Returns 2 if an error occurs.
set -eu
if ! [ $# = 1 ]; then
echo "usage: $0 <filename>"
exit 2
fi
file="$1"
# Don't require deleted files to have a copyright
if ! [ -e "$file" ]; then
exit 1
fi
skipextensions="rst png html in" # List of extensions that cannot have copyrights.
# .rst -> file used to generate documentation. Since final documentation has
# copyrights, this one does not require it.
# .png -> these are images (i.e. binary files) used in the documentation.
# Same reason as .rst for not requiring a copyright.
# .html -> there are a couple of files currently under doc/templates which don't need copyrights.
# .in -> e.g. ydbposix.xc.in stores the external-call/call-out table which does not currently
# have a provision for comment characters.
if echo "$skipextensions" | grep -q -w "$(echo "$file" | awk -F . '{print $NF}')"; then
exit 1
fi
# Below is a list of specific files that do not have a copyright so ignore them
skiplist="COPYING README.md libmath.ref"
for skipfile in $skiplist; do
if [ $file = $skipfile ]; then
exit 1
fi
done