| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function cli_readFileContent { |
| |
| local FILES="$1" |
| local PATTERN='Copyright (\(C\)|©) [0-9]+(-[0-9]+)? .+' |
| |
| |
| cli_checkFiles "$FILES" |
| |
| |
| case "$2" in |
| |
| '--copyright-line' ) |
| cat "$FILES" | egrep "^ +${PATTERN}$" | head -n 1 | sed -r 's!^ +!!' |
| ;; |
| |
| '--last-line' ) |
| cat "$FILES" | tail -n 1 |
| ;; |
| |
| '--copyright-year' ) |
| if [[ $(cli_readFileContent "$FILES" '--copyright-line') =~ "^${PATTERN}$" ]];then |
| cli_readFileContent "$FILES" '--copyright-line' | cut -d' ' -f3 |
| fi |
| ;; |
| |
| '--copyright-holder' ) |
| if [[ $(cli_readFileContent "$FILES" '--copyright-line') =~ "^${PATTERN}$" ]];then |
| cli_readFileContent "$FILES" '--copyright-line' | cut -d' ' -f4- |
| fi |
| ;; |
| |
| '--all-lines' | * ) |
| cat "$FILES" |
| ;; |
| |
| esac |
| |
| } |