OlivierDAZEL/PLANES — pull request #1 by Matael (2014-12-13 14:17:18+00:00)
Title: Add header and license notice on all files

The useful script :

#! /bin/bash
#
# add_header.sh
#
# Copyright © 2014 Mathieu Gaborit (matael)
#
#
# Distributed under WTFPL terms
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
#
# 0. You just DO WHAT THE FUCK YOU WANT TO.
#

generic_header="%\n% Copyright (C) 2014 < Olivier DAZEL >\n%\n% This file is part of PLANES.\n%\n% PLANES (Porous LAum NumErical Simulator) is a software to compute the\n% vibroacoustic response of sound packages containing coupled\n% acoustic/elastic/porous substructures. It is mainly based on the\n% Finite-Element Method and some numerical methods developped at\n% LAUM (http://laum.univ-lemans.fr).\n%\n% You can download the latest version of PLANES at\n% https://github.com/OlivierDAZEL/PLANES\n% or find more details on Olivier's webpage\n% http://perso.univ-lemans.fr/~odazel/\n%\n% For any questions or if you want to\n% contribute to this project, contact Olivier.\n%\n% PLANES is free software: you can redistribute it and/or modify\n% it under the terms of the GNU General Public License as published by\n% the Free Software Foundation, either version 3 of the License, or\n% (at your option) any later version.\n%\n% This program is distributed in the hope that it will be useful,\n% but WITHOUT ANY WARRANTY; without even the implied warranty of\n% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n% GNU General Public License for more details.\n%\n% You should have received a copy of the GNU General Public License\n% along with this program. If not, see .\n%%\n\n"

tmpfile="content_tmp"
orig=$PWD
for dir in $(find ./ -type d); do
cd $dir
for f in *.m*; do
if [[ "${f:$((${#str}-1)):1}" == "~" ]]; then
filename="${f::-1}"
else
filename="$f"
fi
echo "Working on $dir/$f"
cp $f $tmpfile
echo "% $filename" > $f
echo -e $generic_header >> $f
cat $tmpfile>> $f
done
rm $tmpfile
cd $orig
done