gdp / adm / update-license.awk @ master
History | View | Annotate | Download (627 Bytes)
1 |
# |
---|---|
2 |
# Script to update a license block |
3 |
# |
4 |
# Replaces everything between start/stop headers with a new license |
5 |
# |
6 |
|
7 |
BEGIN { |
8 |
saveRS = RS |
9 |
RS = "^$" |
10 |
licenseFile = "LICENSE" |
11 |
getline licenseText < licenseFile |
12 |
sub(/\n$/, "", licenseText) |
13 |
close(licenseFile) |
14 |
RS = saveRS |
15 |
} |
16 |
/----- BEGIN LICENSE BLOCK -----/ { |
17 |
if ($1 == "-----") $1 = "" |
18 |
prefix = "\n" $1 "\t" |
19 |
gsub(/\n/, prefix, licenseText) |
20 |
gsub(/[\t ]*\n/, "\n", licenseText) # strip trailing white space |
21 |
|
22 |
print $1 "\t" licenseText |
23 |
skipText = 1 |
24 |
} |
25 |
/----- END LICENSE BLOCK -----/ { |
26 |
skipText = 0 |
27 |
} |
28 |
skipText == 0 { |
29 |
|
30 |
} |