Blame Manuals/Repository/repository-html/repository_59.html

4c79b5
4c79b5
<html>
ccb7a3
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
-->
bf28e1
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>
42563b
<title>CentOS Artwork Repository: 3.56 trunk/Scripts/Bash/Functions/Shell</title>
4c79b5
42563b
<meta name="description" content="CentOS Artwork Repository: 3.56 trunk/Scripts/Bash/Functions/Shell">
42563b
<meta name="keywords" content="CentOS Artwork Repository: 3.56 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
300762
2c3589
[ < ]
2c3589
[ > ]
4c79b5
   
4c79b5
[ << ]
300762
[ Up ]
42563b
[ >> ]
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
[Top]
4c79b5
[Contents]
42563b
[Index]
4c79b5
[ ? ]
4c79b5
42563b
2c3589
42563b

3.56 trunk/Scripts/Bash/Functions/Shell

38bcd9
c9b54d
2c3589
63f275

3.56.1 Goals

54b5a5
42563b

This section exists to organize files related to shell

2c3589
functionality of <tt>`centos-art.sh'</tt> script.
4a9d2a

4c79b5
2c3589
63f275

3.56.2 Description

5fb024
42563b

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

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

42563b

When you use shell functionality to update copyright inside

42563b
script files, it is required that your script files contain (at least)
42563b
the following top commentary structure:
7fa1fb

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

Figure 3.4: The functions script base comment structure

42563b
c12cdc

42563b

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

42563b
Everything else in the file is left immutable.
bf28e1

42563b

When you are updating copyright through shell

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

42563b
Caution

Caution

Be sure to add the long dash separator that matches

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

42563b
42563b

The copyright template instance is created from one copyright template

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

42563b

When you use shell functionality to update copyright, the first

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

42563b

When shell functionality uses its own default values, the final

42563b
copyright note looks like the following:
7e35dc

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

Figure 3.5: The function script comment example

42563b
7e35dc

42563b

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

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

42563b

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

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

42563b

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

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

42563b
Important

Important

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

c12cdc

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

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

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

d11e55
2c3589
42563b
2c3589

3.56.3 Usage

2c3589
2c3589
42563b
centos-art sh --update-copyright='path/to/dir'
42563b
centos-art sh --update-copyright='path/to/dir' --filter='regex'
42563b

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

42563b
under <samp>`path/to/dir'</samp> directory. 
2c3589

2c3589
2c3589
2c3589

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

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

2c3589
Warning

Warning

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

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

2c3589
42563b

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

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

2c3589

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

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

2c3589
42563b
300762

3.56.4 See also

300762
4a9d2a
42563b
3.48 trunk/Scripts/Bash  
4a9d2a
42563b
3.49 trunk/Scripts/Bash/Functions  
4a9d2a
4a9d2a
081970
081970
300762
42563b
[ < ]
42563b
[ > ]
300762
   
300762
[ << ]
2c3589
[ Up ]
42563b
[ >> ]
300762
4c79b5

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

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