Skip to content
Snippets Groups Projects
  • Tobias Hunger's avatar
    469e1d09
    Add scripts to check/fix copyright headers. · 469e1d09
    Tobias Hunger authored
     * Add a script that will report files without copyright headers.
       (see hasCopyright.sh for sample usage).
     * Add a script that will add a header to files.
       (see fixCopyright.sh for sample usage).
    
    Reviewed-by: Roberto Raggi
    469e1d09
    History
    Add scripts to check/fix copyright headers.
    Tobias Hunger authored
     * Add a script that will report files without copyright headers.
       (see hasCopyright.sh for sample usage).
     * Add a script that will add a header to files.
       (see fixCopyright.sh for sample usage).
    
    Reviewed-by: Roberto Raggi
hasCopyright.sh 487 B
#!/bin/sh

# Scan files given on the command line for a copyright header.
# Only the first 15 lines will be examined and must contain the
# string 'Copyright'.
#
# Sample usage:
# find . -type f -name \*.cpp -o -name \*.h | xargs ~/bin/hasCopyright.sh

for i in $@ ; do
    if test -f "$i" && test -s "$i" ; then
        if head -n 15 "$i" | grep Copyright > /dev/null 2>&1 ; then
            echo "$i: Copyright."
        else
           echo "$i: NO COPYRIGHT."
        fi
    fi
done