Blame Manuals/en/Html/Repository/repository_47.html

4c79b5
4c79b5
<html>
6414c4
09d4f2
6414c4
Copyright C 2009, 2010, 2011  Alain Reguera Delgado
4c79b5
4c79b5
Permission is granted to copy, distribute and/or modify this document
4c79b5
under the terms of the GNU Free Documentation License, Version 1.2 or
4c79b5
any later version published by the Free Software Foundation; with no
4c79b5
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
4c79b5
copy of the license is included in the section entitled GNU Free
4c79b5
Documentation License.  
4c79b5
-->
27dad7
4c79b5
4c79b5
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
4c79b5
            Karl Berry  <karl@freefriends.org>
4c79b5
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
4c79b5
            and many others.
4c79b5
Maintained by: Many creative people <dev@texi2html.cvshome.org>
4c79b5
Send bugs and suggestions to <users@texi2html.cvshome.org>
4c79b5
4c79b5
-->
4c79b5
<head>
ec5f63
<title>The CentOS Artwork Repository: 3.44 trunk/Scripts/Bash/Functions/Shell</title>
4c79b5
ec5f63
<meta name="description" content="The CentOS Artwork Repository: 3.44 trunk/Scripts/Bash/Functions/Shell">
ec5f63
<meta name="keywords" content="The CentOS Artwork Repository: 3.44 trunk/Scripts/Bash/Functions/Shell">
4c79b5
<meta name="resource-type" content="document">
4c79b5
<meta name="distribution" content="global">
4c79b5
<meta name="Generator" content="texi2html 1.76">
4c79b5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4c79b5
<style type="text/css">
4c79b5
1e9202
@import "/home/centos/artwork/trunk/Identity/Models/Css/Texi2html/common.css";
4c79b5
4c79b5
a.summary-letter {text-decoration: none}
4c79b5
pre.display {font-family: serif}
4c79b5
pre.format {font-family: serif}
4c79b5
pre.menu-comment {font-family: serif}
4c79b5
pre.menu-preformatted {font-family: serif}
4c79b5
pre.smalldisplay {font-family: serif; font-size: smaller}
4c79b5
pre.smallexample {font-size: smaller}
4c79b5
pre.smallformat {font-family: serif; font-size: smaller}
4c79b5
pre.smalllisp {font-size: smaller}
4c79b5
span.sansserif {font-family:sans-serif; font-weight:normal;}
4c79b5
ul.toc {list-style: none}
4c79b5
-->
4c79b5
</style>
4c79b5
4c79b5
4c79b5
</head>
4c79b5
4c79b5
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
4c79b5
4c79b5
ec5f63
[ < ]
ec5f63
[ > ]
4c79b5
   
4c79b5
[ << ]
4c79b5
[ Up ]
ec5f63
[ >> ]
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
[Top]
4c79b5
[Contents]
ec5f63
[Index]
4c79b5
[ ? ]
4c79b5
ec5f63
ec5f63
ec5f63

3.44 trunk/Scripts/Bash/Functions/Shell

008ee0
ef356a
ec5f63
54b5a5

3.44.1 Goals

54b5a5
ec5f63

This section exists to organize files related to shell

ec5f63
functionality of <tt>`centos-art.sh'</tt> script.
63f275

008ee0
ec5f63
54b5a5

3.44.2 Description

54b5a5
ec5f63

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

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

ec5f63

When you use shell functionality to update copyright inside

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

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

Figure 3.20: The functions script base comment structure

ec5f63
0151ba

ec5f63

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

ec5f63
Everything else in the file is left immutable.
3d6160

ec5f63

When you are updating copyright through shell

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

ec5f63
Caution

Caution

Be sure to add the long dash separator that matches

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

0d952c
ec5f63

The copyright template instance is created from one copyright template

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

ec5f63

When you use shell functionality to update copyright, the first

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

ec5f63

When shell functionality uses its own default values, the final

ec5f63
copyright note looks like the following:
60c152

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

Figure 3.21: The function script comment example

ec5f63
6414c4

ec5f63

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

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

ec5f63

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

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

ec5f63

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

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

ec5f63
Important

Important

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

3f9ae1

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

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

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

ec5f63
e37211
01b527
008ee0

3.44.3 Usage

008ee0
63f275
ec5f63
centos-art sh --update-copyright='path/to/dir'
ec5f63
centos-art sh --update-copyright='path/to/dir' --filter='regex'
ec5f63

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

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

3f9ae1
3f9ae1
ec5f63

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

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

ec5f63
Warning

Warning

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

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

ec5f63
ec5f63

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

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

ec5f63

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

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

63f275
01b527
4c79b5

3.44.4 See also

4c79b5
2c8180
ec5f63
3.36 trunk/Scripts/Bash  
63f275
ec5f63
3.37 trunk/Scripts/Bash/Functions  
2c8180
2c8180
4c79b5
4c79b5
4c79b5
01b527
[ < ]
01b527
[ > ]
4c79b5
   
4c79b5
[ << ]
ec5f63
[ Up ]
ec5f63
[ >> ]
4c79b5
4c79b5

4c79b5
 <font size="-1">
27dad7
  This document was generated on January, 6 2011 using texi2html 1.76.
4c79b5
 </font>
4c79b5
 
4c79b5
4c79b5

4c79b5
</body>
4c79b5
</html>