Blame Identity/Manual/repository-xhtml/repository_79.xhtml

c8f7b7
728c6d
728c6d
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
728c6d
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
728c6d
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
632e8b
<head>
632e8b
a6f1b3
    <title>CentOS Artwork Repository: 2.72 The trunk/Scripts/Functions/Shell Directory</title>
c8f7b7
c8f7b7
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
a6f1b3
    <meta name="description" content="CentOS Artwork Repository: 2.72 The trunk/Scripts/Functions/Shell Directory" />
a6f1b3
    <meta name="keywords" content="CentOS Artwork Repository: 2.72 The trunk/Scripts/Functions/Shell Directory" />
728c6d
    <meta name="resource-type" content="document" />
728c6d
    <meta name="distribution" content="global" />
728c6d
    <meta name="generator" content="texi2html 1.76" />
728c6d
    <meta name="copyright" content="2009-2011 Alain Reguera Delgado" />
632e8b
c8f7b7
    <link href="/home/centos/artwork/trunk/Identity/Manual/repository.css" rel="stylesheet" type="text/css" media="screen projection" />
632e8b
632e8b
</head>
632e8b
728c6d
<body>
632e8b
728c6d
728c6d
728c6d
728c6d
728c6d
    
728c6d
728c6d
        
c8f7b7
a6f1b3
632e8b
a6f1b3
[ < ]
a6f1b3
[ > ]
632e8b
   
c8f7b7
[ << ]
c8f7b7
[ Up ]
a6f1b3
[ >> ]
632e8b
   
632e8b
   
632e8b
   
632e8b
   
c8f7b7
[Top]
c8f7b7
[Contents]
a6f1b3
[Index]
c8f7b7
[ ? ]
632e8b
a6f1b3
ed9de5
a6f1b3

2.72 The <tt>`trunk/Scripts/Functions/Shell'</tt> Directory

06d106
728c6d

ed9de5
a6f1b3

2.72.1 Goals

06d106
a6f1b3

This section exists to organize files related to shell

a6f1b3
functionality of <tt>`centos-art.sh'</tt> script.
ed9de5

728c6d

ed9de5
a6f1b3

2.72.2 Description

ed9de5
a6f1b3

The shell functionality of <tt>`centos-art.sh'</tt> script helps

a6f1b3
you to maintain bash scripts inside repository. For example, suppose
a6f1b3
you've created many functionalities for <tt>`centos-art.sh'</tt> script,
a6f1b3
and you want to use a common copyright and license note for
a6f1b3
consistency in all your script files. If you have a bunch of files,
a6f1b3
doing this one by one wouldn't be a big deal. In contrast, if the
a6f1b3
amount of files grows, updating the copyright and license note for all
a6f1b3
of them would be a task rather tedious. The shell functionality
a6f1b3
exists to solve maintainance tasks just as the one previously
a6f1b3
mentioned.
a6f1b3

a6f1b3

When you use shell functionality to update copyright inside

a6f1b3
script files, it is required that your script files contain (at least)
a6f1b3
the following top commentary structure:
a6f1b3

a6f1b3
a6f1b3
 1| #!/bin/bash
a6f1b3
 2| #
a6f1b3
 3| # doSomething.sh -- The function description goes here.
a6f1b3
 4| # 
a6f1b3
 5| # Copyright
a6f1b3
 6| #
a6f1b3
 7| # ...
a6f1b3
 8| #
a6f1b3
 9| # ----------------------------------------------------------------------
a6f1b3
10| # $Id$
a6f1b3
11| # ----------------------------------------------------------------------
a6f1b3
12|
a6f1b3
13| function doSomething {
a6f1b3
14|     
a6f1b3
15| }
a6f1b3
a6f1b3

Figure 2.4: The functions script base comment structure

a6f1b3
a6f1b3

a6f1b3

Relevant lines in the above structure are lines from 5 to 9.

a6f1b3
Everything else in the file is left immutable.
a6f1b3

a6f1b3

When you are updating copyright through shell

a6f1b3
functionality,  the <tt>`centos-art.sh'</tt> script replaces everything
a6f1b3
in-between line 5 --the first one matching <samp>`^# Copyright .+$'</samp>
a6f1b3
string-- and line 9--the first long dash separator matching <samp>`^#
a6f1b3
-+$'</samp>-- with the content of copyright template instance.
a6f1b3

a6f1b3
Caution

Caution

Be sure to add the long dash separator that matches

a6f1b3
<samp>`^# -+$'</samp> regular expression before the function
a6f1b3
definition. Otherwise, if the <samp>`Copyright'</samp> line is present but no
a6f1b3
long dash separator exists, <tt>`centos-art.sh'</tt> will remove anything
a6f1b3
in-between the <samp>`Copyright'</samp> line and the end of file. This way you
a6f1b3
may lost your function definitions entirely.
06d106

06d106
a6f1b3

The copyright template instance is created from one copyright template

a6f1b3
stored in the <tt>`Config/tpl_forCopyright.sed'</tt> file.  The template
a6f1b3
instance is created once, and later removed when no longer needed. At
a6f1b3
this moment, when template instance is created, the
a6f1b3
<tt>`centos-art.sh'</tt> script takes advantage of automation in order to
a6f1b3
set copyright full name and date dynamically.
a6f1b3

a6f1b3

When you use shell functionality to update copyright, the first

a6f1b3
thing <tt>`shell'</tt> functionality does is requesting copyright
a6f1b3
information to user, and later, if values were left empty (i.e., no
a6f1b3
value was typed before pressing RET key), the <tt>`shell'</tt>
a6f1b3
functionality uses its own default values.
a6f1b3

a6f1b3

When shell functionality uses its own default values, the final

a6f1b3
copyright note looks like the following:
a6f1b3

a6f1b3
a6f1b3
 1| #!/bin/bash
a6f1b3
 2| #
a6f1b3
 3| # doSomthing.sh -- The function description goes here.
a6f1b3
 4| #
a6f1b3
 5| # Copyright (C) 2003, 2010 The CentOS Project
a6f1b3
 6| # 
a6f1b3
 7| # This program is free software; you can redistribute it and/or modify
a6f1b3
 8| # it under the terms of the GNU General Public License as published by
a6f1b3
 9| # the Free Software Foundation; either version 2 of the License, or
a6f1b3
10| # (at your option) any later version.
a6f1b3
11| # 
a6f1b3
12| # This program is distributed in the hope that it will be useful, but
a6f1b3
13| # WITHOUT ANY WARRANTY; without even the implied warranty of
a6f1b3
14| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
a6f1b3
15| # General Public License for more details.
a6f1b3
16| #
a6f1b3
17| # You should have received a copy of the GNU General Public License
a6f1b3
18| # along with this program; if not, write to the Free Software
a6f1b3
19| # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
a6f1b3
20| # USA.
a6f1b3
21| #
a6f1b3
22| # ----------------------------------------------------------------------
a6f1b3
23| # $Id$
a6f1b3
24| # ----------------------------------------------------------------------
a6f1b3
25|
a6f1b3
26| function doSomething {
a6f1b3
27|
a6f1b3
28| }
a6f1b3
a6f1b3

Figure 2.5: The function script comment example

a6f1b3
a6f1b3

a6f1b3

Relevant lines in the above structure are lines from 5 to 22. Pay

a6f1b3
attention how the copyright line was built, and how the license was
a6f1b3
added into the top comment where previously was just three dots.
a6f1b3
Everything else in the file was left immutable. 
a6f1b3

a6f1b3

To change copyright information (i.e., full name or year information),

a6f1b3
run the shell functionality over the root directory containing
a6f1b3
the script files you want to update copyright in and enter the
a6f1b3
appropriate information when it be requested. You can run the
a6f1b3
shell functionality as many times as you need to.
a6f1b3

a6f1b3

To change copyright license (i.e., the text in-between lines 7 and

a6f1b3
20), you need to edit the <tt>`Config/tpl_forCopyright.sed'</tt> file, set
a6f1b3
the appropriate information, and run the shell functionality
a6f1b3
once again for changes to take effect over the files you specify.
a6f1b3

a6f1b3
Important

Important

The <tt>`centos-art.sh'</tt> script is released as:

a6f1b3

a6f1b3
GNU GENERAL PUBLIC LICENSE
a6f1b3
Version 2, June 1991
a6f1b3
a6f1b3
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
a6f1b3
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
a6f1b3
a6f1b3

Do not change the license information under which <tt>`centos-art.sh'</tt>

a6f1b3
script is released. Instead, if you think a different license must be
a6f1b3
used, please share your reasons at CentOS Developers mailing list.
a6f1b3

ed9de5
728c6d

a6f1b3
a6f1b3

2.72.3 Usage

06d106
06d106
a6f1b3
centos-art sh --update-copyright='path/to/dir'
a6f1b3
centos-art sh --update-copyright='path/to/dir' --filter='regex'
a6f1b3

Use these commands to update copyright information in <samp>`.sh'</samp> files

a6f1b3
under <samp>`path/to/dir'</samp> directory. 
a6f1b3

a6f1b3
ed9de5
a6f1b3

When you provide <samp>`--filter='regex''</samp> argument, the list of files

a6f1b3
to process is reduced as specified in <samp>`regex'</samp> regular expression.
a6f1b3
Inside <tt>`centos-art.sh'</tt> script, the <samp>`regex'</samp> regular
a6f1b3
expression is used in combination with find command to look
a6f1b3
for files matching the regular expression path pattern.
ed9de5

a6f1b3
Warning

Warning

In order for <samp>`regex'</samp> regular expression to match

a6f1b3
a file, the <samp>`regex'</samp> regular expresion must match the whole file
a6f1b3
path not just the file name. 
ed9de5

ed9de5
a6f1b3

For example, if you want to match all <tt>`render.conf.sh'</tt> files

a6f1b3
inside <tt>`path/to/dir'</tt>, use the .+/render.conf regular
a6f1b3
expression.  Later, <tt>`centos-art.sh'</tt> script uses this value inside
a6f1b3
^$REGEX\.sh$ expression in order to build the final regular
a6f1b3
expression (i.e., ^.+/render.conf\.sh$) that is evaluated
a6f1b3
against available file paths inside the list of files to process.
ed9de5

a6f1b3

Exceptionally, when you provide <samp>`--filter='regex''</samp> in the way

a6f1b3
that <samp>`regex'</samp>, appended to <samp>`path/to/dir/'</samp> (i.e.
a6f1b3
<samp>`path/to/dir/regex'</samp>), matches a regular file; the
a6f1b3
<tt>`centos-art.sh'</tt> script uses the file matching as only file in the
a6f1b3
list of files to process. 
ed9de5

728c6d

a6f1b3
52772c

2.72.4 See also

06d106
06d106
a6f1b3
2.62 The <tt>`trunk/Scripts'</tt> Directory  
06d106
9bfd15
632e8b
728c6d

632e8b
a6f1b3
[ < ]
a6f1b3
[ > ]
632e8b
   
c8f7b7
[ << ]
a6f1b3
[ Up ]
a6f1b3
[ >> ]
632e8b
632e8b
728c6d
            

728c6d
728c6d
        
728c6d
728c6d
    
728c6d
728c6d
    

728c6d
728c6d
728c6d
632e8b
</body>
728c6d
632e8b
</html>