|
|
be7de3 |
#!/bin/bash
|
|
|
be7de3 |
#
|
|
|
be7de3 |
# tuneup_doShellTopComment.sh -- This function tunnes up the top
|
|
|
be7de3 |
# comment section inside shell scripts (*.sh) using a predefined
|
|
|
be7de3 |
# template.
|
|
|
be7de3 |
#
|
|
|
be7de3 |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
fa95b1 |
# the Free Software Foundation; either version 2 of the License, or
|
|
|
fa95b1 |
# (at your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
be7de3 |
# This program is distributed in the hope that it will be useful, but
|
|
|
be7de3 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
be7de3 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
be7de3 |
# General Public License for more details.
|
|
|
be7de3 |
#
|
|
|
be7de3 |
# You should have received a copy of the GNU General Public License
|
|
|
be7de3 |
# along with this program; if not, write to the Free Software
|
|
|
be7de3 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
be7de3 |
# USA.
|
|
|
be7de3 |
# ----------------------------------------------------------------------
|
|
|
be7de3 |
# $Id$
|
|
|
be7de3 |
# ----------------------------------------------------------------------
|
|
|
be7de3 |
|
|
|
be7de3 |
function tuneup_doShellTopComment {
|
|
|
be7de3 |
|
|
|
be7de3 |
# Define absolute path to template file.
|
|
|
be7de3 |
local TEMPLATE="${FUNCCONFIG}/shell_topcomment.sed"
|
|
|
be7de3 |
|
|
|
be7de3 |
# Check template file existence.
|
|
|
be7de3 |
cli_checkFiles $TEMPLATE 'f'
|
|
|
be7de3 |
|
|
|
be7de3 |
# Define file name to template instance.
|
|
|
be7de3 |
local INSTANCE=$(cli_getTemporalFile $TEMPLATE)
|
|
|
be7de3 |
|
|
|
be7de3 |
# Create template instance.
|
|
|
be7de3 |
cp $TEMPLATE $INSTANCE
|
|
|
be7de3 |
|
|
|
be7de3 |
# Check template instance. We cannot continue if template instance
|
|
|
be7de3 |
# couldn't be created.
|
|
|
be7de3 |
cli_checkFiles $INSTANCE 'f'
|
|
|
be7de3 |
|
|
|
be7de3 |
# Expand translation markers in template instance.
|
|
|
be7de3 |
cli_replaceTMarkers $INSTANCE
|
|
|
be7de3 |
|
|
|
be7de3 |
# Apply template instance to file.
|
|
|
be7de3 |
sed -r -i -f $INSTANCE $FILE
|
|
|
be7de3 |
|
|
|
be7de3 |
# Remove template instance.
|
|
|
be7de3 |
if [[ -f ${INSTANCE} ]];then
|
|
|
be7de3 |
rm ${INSTANCE}
|
|
|
be7de3 |
fi
|
|
|
be7de3 |
|
|
|
be7de3 |
}
|