3 # Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
5 # Licensed under the OpenSSL license (the "License"). You may not use
6 # this file except in compliance with the License. You can obtain a copy
7 # in the file LICENSE in the source distribution or at
8 # https://www.openssl.org/source/license.html
11 myname="$(basename $0)"
13 this_year="$(date '+%Y')"
14 some_year="[12][0-9][0-9][0-9]"
15 year_range="(${some_year})(-${some_year})?"
17 copyright_owner="The OpenSSL Project"
18 copyright="Copyright .*${year_range} .*${copyright_owner}"
21 # for all lines that contain ${copyright} : {
22 # replace years yyyy-zzzz (or year yyyy) by yyyy-${this_year}
23 # replace repeated years yyyy-yyyy by yyyy
25 sed_script="/${copyright}/{ s/${year_range}/\1-${this_year}/ ; s/(${some_year})-\1/\1/ }"
29 usage: $myname [-h|--help] [file|directory] ...
31 Updates the year ranges of all OpenSSL copyright statements in the given
32 files or directories. (Directories are traversed recursively.)
49 echo -e "illegal option: $arg\n" >& 2
54 if [ -f "$arg" ]; then
55 sed -E -i "${sed_script}" "$arg"
56 elif [ -d "$arg" ]; then
57 find "$arg" -name '.[a-z]*' -prune -o -type f -exec sed -E -i "${sed_script}" {} +
59 echo "$arg: no such file or directory" >&2