Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions addcopyright.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
#!/bin/bash

## Solution found as part of this stackoverflow discussion: https://stackoverflow.com/questions/151677/tool-for-adding-license-headers-to-source-files
if [ -n "${DEBUG}" ];
then
echo "Debug Mode, display commands & dry-run (no actual modifications to files)."
set -x
fi

for x in $*; do
head -$COPYRIGHTLEN $x | diff copyright.txt - || ( ( cat copyright.txt; echo; cat $x) > /tmp/file;
mv /tmp/file $x )
if [ -z "${1}" ] || [ -d "${1}" ];
then
WORKDIR="${1}"
else
WORKDIR="."
fi


find "${WORKDIR}" -type f -not -path "./.git/*" -print0 | while IFS= read -r -d '' file_name
do
isTextFile=$(file --no-buffer -i "${file_name}" )
if [[ "${isTextFile}" =~ ".* text/plain;.*" ]];
then
echo "${file_name} skipped (not text),"
continue;
fi

if [ -n "${DEBUG}" ];
then
echo "Skip ${file_name}, debug is dry-run mode."
continue;
fi

## Solution found as part of this stackoverflow discussion: https://stackoverflow.com/questions/151677/tool-for-adding-license-headers-to-source-files
head "-${COPYRIGHTLEN}" "${file_name}" | diff copyright.txt - || ( ( cat copyright.txt; echo; cat "${file_name}") > /tmp/file; \
mv /tmp/file "${file_name}" )
done


Binary file added drill/abcd.zip
Binary file not shown.