Blame Manual/repository-html/repository_77.html

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

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

632e8b
632e8b
06d106
632e8b

2.73.1 Goals

632e8b
06d106

This section exists to organize files related to shell

06d106
functionality of <tt>`centos-art.sh'</tt> script.
9bfd15

632e8b
06d106
632e8b

2.73.2 Description

632e8b
06d106

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

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

06d106

When you use shell functionality to update copyright inside

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

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

Figure 2.4: The functions script base comment structure

06d106
06d106

06d106

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

06d106
Everything else in the file is left immutable.
06d106

06d106

When you are updating copyright through shell

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

06d106
Caution

Caution

Be sure to add the long dash separator that matches

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

632e8b
06d106

The copyright template instance is created from one copyright template

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

06d106

When you use shell functionality to update copyright, the first

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

06d106

When shell functionality uses its own default values, the final

06d106
copyright note looks like the following:
06d106

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

Figure 2.5: The function script comment example

06d106
06d106

06d106

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

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

06d106

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

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

06d106

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

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

06d106
Important

Important

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

06d106

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

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

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

9bfd15
9bfd15
06d106
06d106

2.73.3 Usage

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

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

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

06d106
632e8b
06d106

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

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

06d106
Warning

Warning

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

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

632e8b
06d106

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

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

06d106

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

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

632e8b
06d106
9bfd15

2.73.4 See also

632e8b
9bfd15
06d106
2.62 The <tt>`trunk/Scripts/Bash'</tt> Directory  
9bfd15
9bfd15
632e8b
632e8b
632e8b
06d106
[ < ]
06d106
[ > ]
632e8b
   
632e8b
[ << ]
06d106
[ Up ]
06d106
[ >> ]
632e8b
632e8b

632e8b
 <font size="-1">
949b9b
  This document was generated on March, 11 2011 using texi2html 1.76.
632e8b
 </font>
632e8b
 
632e8b
632e8b

632e8b
</body>
632e8b
</html>