Blame Scripts/Functions/Tuneup/tuneup_doShellTopComment.sh

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
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# 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
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, 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
}