Blame Manual/repository-html/repository_65.html

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

2.60 The <tt>`trunk/Scripts/Bash/Cli/Functions/Shell'</tt> Directory

b130a0
b9dbd3
f66721
f66721

2.60.1 Goals

b9dbd3
f66721

This section exists to organize files related to shell

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

063806
f66721
f66721

2.60.2 Description

b9dbd3
f66721

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

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

f66721

When you use shell functionality to update copyright inside

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

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

Figure 2.4: The functions script base comment structure

f66721
063806

f66721

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

f66721
Everything else in the file is left immutable.
063806

f66721

When you are updating copyright through shell

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

f66721
Caution

Caution

Be sure to add the long dash separator that matches

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

f66721
f66721

The copyright template instance is created from one copyright template

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

f66721

When you use shell functionality to update copyright, the first

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

f66721

When shell functionality uses its own default values, the final

f66721
copyright note looks like the following:
063806

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

Figure 2.5: The function script comment example

f66721
063806

f66721

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

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

f66721

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

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

f66721

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

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

f66721
Important

Important

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

063806

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

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

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

b9dbd3
b9dbd3
f66721
f66721

2.60.3 Usage

b9dbd3
063806
f66721
centos-art sh --update-copyright='path/to/dir'
f66721
centos-art sh --update-copyright='path/to/dir' --filter='regex'
f66721

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

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

063806
b130a0
063806

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

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

063806
Warning

Warning

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

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

b130a0
f66721

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

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

063806

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

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

b130a0
f66721
f66721

2.60.4 See also

982d5c
063806
f66721
2.50 The <tt>`trunk/Scripts/Bash'</tt> Directory  
063806
063806
ee1f37
ee1f37
ee1f37
f66721
[ < ]
f66721
[ > ]
ee1f37
   
f66721
[ << ]
f66721
[ Up ]
f66721
[ >> ]
ee1f37
ee1f37

ee1f37
 <font size="-1">
406f69
  This document was generated on March, 1 2011 using texi2html 1.76.
ee1f37
 </font>
ee1f37
 
ee1f37
ee1f37

ee1f37
</body>
ee1f37
</html>