Blame Manuals/Repository/repository-html/repository_60.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
-->
acd47b
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>
fa7cae
<title>CentOS Artwork Repository: 3.57 trunk/Scripts/Bash/Functions/Shell</title>
4c79b5
fa7cae
<meta name="description" content="CentOS Artwork Repository: 3.57 trunk/Scripts/Bash/Functions/Shell">
fa7cae
<meta name="keywords" content="CentOS Artwork Repository: 3.57 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
2dc146
[ < ]
2dc146
[ > ]
4c79b5
   
4c79b5
[ << ]
38bcd9
[ Up ]
fa7cae
[ >> ]
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
   
4c79b5
[Top]
4c79b5
[Contents]
fa7cae
[Index]
4c79b5
[ ? ]
4c79b5
fa7cae
2dc146
fa7cae

3.57 trunk/Scripts/Bash/Functions/Shell

4a9d2a
4a9d2a
2dc146
4a9d2a

3.57.1 Goals

4a9d2a
fa7cae

This section exists to organize files related to shell

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

4a9d2a
2dc146
4a9d2a

3.57.2 Description

4a9d2a
fa7cae

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

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

fa7cae

When you use shell functionality to update copyright inside

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

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

Figure 3.4: The functions script base comment structure

fa7cae
4a9d2a

fa7cae

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

fa7cae
Everything else in the file is left immutable.
4a9d2a

fa7cae

When you are updating copyright through shell

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

fa7cae
Caution

Caution

Be sure to add the long dash separator that matches

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

fa7cae
fa7cae

The copyright template instance is created from one copyright template

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

fa7cae

When you use shell functionality to update copyright, the first

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

fa7cae

When shell functionality uses its own default values, the final

fa7cae
copyright note looks like the following:
4a9d2a

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

Figure 3.5: The function script comment example

fa7cae
4a9d2a

fa7cae

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

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

fa7cae

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

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

fa7cae

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

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

fa7cae
Important

Important

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

4a9d2a

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

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

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

2dc146
2dc146
fa7cae
008ee0

3.57.3 Usage

008ee0
4a9d2a
fa7cae
centos-art sh --update-copyright='path/to/dir'
fa7cae
centos-art sh --update-copyright='path/to/dir' --filter='regex'
fa7cae

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

fa7cae
under <samp>`path/to/dir'</samp> directory. 
2dc146

4a9d2a
4a9d2a
2dc146

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

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

2dc146
Warning

Warning

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

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

2dc146
fa7cae

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

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

2dc146

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

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

008ee0
fa7cae
38bcd9

3.57.4 See also

38bcd9
4a9d2a
fa7cae
3.49 trunk/Scripts/Bash  
4a9d2a
fa7cae
3.50 trunk/Scripts/Bash/Functions  
4a9d2a
4a9d2a
008ee0
6aec21
300762
fa7cae
[ < ]
fa7cae
[ > ]
300762
   
300762
[ << ]
2dc146
[ Up ]
fa7cae
[ >> ]
300762
4c79b5

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

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