1
+ #! /usr/bin/env bash
2
+
1
3
# ###############################################################################
2
- # Copyright 2017 General Electric Company
4
+ # Copyright 2018 General Electric Company
3
5
#
4
6
# Licensed under the Apache License, Version 2.0 (the "License");
5
7
# you may not use this file except in compliance with the License.
16
18
# SPDX-License-Identifier: Apache-2.0
17
19
# ###############################################################################
18
20
19
- #! /usr/bin/env bash
20
-
21
21
{ set -e; } 2> /dev/null
22
22
23
23
function usage {
@@ -100,7 +100,7 @@ function generate_copyright_header {
100
100
COPYRIGHT_HEADER=" ${COPYRIGHT_HEADER}${BEGINNING_COMMENT_LINE}${NEWLINE} "
101
101
102
102
IFS=" $NEWLINE "
103
- for l in $COPYRIGHT_HEADER_BODY ; do
103
+ for l in ${ COPYRIGHT_HEADER_BODY} ; do
104
104
if [[ " $BEGINNING_COMMENT_MARKER " != " $CONTINUING_COMMENT_MARKER " ]]; then
105
105
COPYRIGHT_HEADER=" ${COPYRIGHT_HEADER} "
106
106
fi
@@ -137,13 +137,17 @@ function upsert_copyright {
137
137
138
138
if [[ " $1 " == ' xml' ]]; then
139
139
echo -e ' <?xml version="1.0" encoding="UTF-8"?>\n' > " $TMP_FILE "
140
+ elif [[ " $1 " == ' sh' ]]; then
141
+ echo -e ' #!/usr/bin/env bash\n' > " $TMP_FILE "
140
142
fi
141
143
142
144
echo " $( generate_copyright_header " $1 " ) " >> " $TMP_FILE "
143
145
echo ' ' >> " $TMP_FILE "
144
146
145
147
if [[ " $1 " == ' xml' ]]; then
146
148
cat " $2 " | awk ' /<\?xml/{y=1;next}y' | sed ' /./,$!d' >> " $TMP_FILE "
149
+ elif [[ " $1 " == ' sh' ]]; then
150
+ cat " $2 " | awk ' /^#!/{y=1;next}y' | sed ' /./,$!d' >> " $TMP_FILE "
147
151
else
148
152
cat " $2 " >> " $TMP_FILE "
149
153
fi
@@ -156,7 +160,7 @@ function upsert_copyright {
156
160
}
157
161
158
162
function normalize_authors {
159
- perl -i -pe ' s/(\@author\s*)\d{1,}/$1acs-engineers\@ge.com/' " $2 "
163
+ perl -i -pe ' s/(\@author\s*)\d{1,}/$1acs-engineers\@ge.com/' " $1 "
160
164
}
161
165
162
166
function modify_copyright_in_file {
@@ -172,7 +176,7 @@ function modify_copyright_in_file {
172
176
173
177
if [[ -n " $NORMALIZE_AUTHORS " ]]; then
174
178
echo " Normalizing author information in file: ${1} with extension: .${EXTENSION} "
175
- normalize_authors " $EXTENSION " " $ 1"
179
+ normalize_authors " $1 "
176
180
fi
177
181
}
178
182
@@ -184,7 +188,8 @@ unset SRC_FILE
184
188
185
189
read_args " $@ "
186
190
187
- DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
191
+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
192
+ ROOT_DIR=" $( cd " ${SCRIPT_DIR} /.." && pwd ) "
188
193
189
194
if [[ -n " $DEBUG " ]]; then
190
195
echo ' The following options are set:'
@@ -193,7 +198,8 @@ if [[ -n "$DEBUG" ]]; then
193
198
echo " NORMALIZE_AUTHORS: ${NORMALIZE_AUTHORS} "
194
199
echo " DEBUG: ${DEBUG} "
195
200
echo " SRC_FILE: ${SRC_FILE} "
196
- echo " DIR: ${DIR} "
201
+ echo " SCRIPT_DIR: ${SCRIPT_DIR} "
202
+ echo " ROOT_DIR: ${ROOT_DIR} "
197
203
echo ' '
198
204
fi
199
205
@@ -211,7 +217,7 @@ if [[ -n "$DEBUG" ]]; then
211
217
fi
212
218
213
219
if [[ -z " $SRC_FILE " ]]; then
214
- for f in $( find " $DIR " \( -not -path ' */\.*' -and -not -path ' */failsafe*' -and -not -path ' */surefire*' \) -type f \( -iname ' *.groovy' -or -iname ' *.java' -or -iname ' *.sh' -or -iname ' *.properties' -or -iname ' *.xml' \) ) ; do
220
+ for f in $( find " $ROOT_DIR " \( -not -path ' */\.*' -and -not -path ' */failsafe*' -and -not -path ' */surefire*' \) -type f \( -iname ' *.groovy' -or -iname ' *.java' -or -iname ' *.sh' -or -iname ' *.properties' -or -iname ' *.xml' \) ) ; do
215
221
modify_copyright_in_file " $f "
216
222
done
217
223
else
0 commit comments