File indexing completed on 2024-12-08 05:05:48
0001 #!/bin/sh 0002 # 0003 # Copyright (c) 2019, Michal Policht. This file is dually licensed under terms of 0004 # either WTFPL or BEER-WARE LICENSE. You may obtain the copy of WTFPL or BEER-WARE 0005 # LICENSE by googling it. NO WARRANTY. YOU WILL PAY ALL COSTS FOR ANY REPAIRS. 0006 # 0007 # Find specific file types and apply license to them. Qualifier is extracted 0008 # from license file name (being highest file extension). 0009 # 0010 # usage: makelic.sh lic_path comment file_types IORS find_program git_program 0011 # example: makelic.sh LICENSE.C.dslash.inc dslash src "*.cpp *.c" "\n" find git 0012 # 0013 # parameters: 0014 # lic_path - path to license file. 0015 # comment - comment type. Passed as comment parameter to putlic.sh. 0016 # file_types - file types for which the license should be applied. 0017 # IORS - input/output record separator (new lines style; typically: "\n" - unix mac "\r\n\ - windows). 0018 # find_program - command to execute findutils find. 0019 # git - command to execute git. 0020 # 0021 # required tools: sh, dirname, find (findutils), putlic.sh. 0022 0023 0024 lic_path=$1 0025 comment=$2 0026 file_types=$3 0027 IORS=$4 0028 find_program=$5 0029 git_program=$6 0030 0031 usage() 0032 { 0033 echo "usage: $0 lic_path comment file_types IORS find_program git_program" 0034 } 0035 0036 if [ $# -lt 6 ]; then 0037 echo "error: too few arguments" 0038 usage 0039 exit 0 0040 fi 0041 0042 0043 dir=$(dirname $lic_path) 0044 lic_filename=${lic_path##*/} 0045 lic_ext=${lic_filename#*.} 0046 lic_qualifier=${lic_ext%%.*} 0047 0048 echo "Applying '${lic_path}' to directory '${dir}'" 0049 set -f # Turn off globbing to prevent $file_types expansion to matched files. 0050 $find_program $dir -type f \( $file_types \) -exec sh awkgward/putlic.sh {} $lic_path $comment $lic_qualifier $IORS $find_program $git_program \; 0051 set +f 0052