|
|
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>
|
|
|
c12cdc |
<title>CentOS Artwork Repository: 3.55 trunk/Scripts/Bash/Functions/Shell</title>
|
|
|
4c79b5 |
|
|
|
c12cdc |
<meta name="description" content="CentOS Artwork Repository: 3.55 trunk/Scripts/Bash/Functions/Shell">
|
|
|
c12cdc |
<meta name="keywords" content="CentOS Artwork Repository: 3.55 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 |
|
|
|
c12cdc |
[ < ]
|
|
|
c12cdc |
[ > ]
|
|
|
4c79b5 |
|
|
|
4c79b5 |
[ << ]
|
|
|
300762 |
[ Up ]
|
|
|
c12cdc |
[ >> ]
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
|
|
|
4c79b5 |
[Top]
|
|
|
4c79b5 |
[Contents]
|
|
|
c12cdc |
[Index]
|
|
|
4c79b5 |
[ ? ]
|
|
|
4c79b5 |
|
|
|
c12cdc |
|
|
|
c12cdc |
|
|
|
c12cdc |
3.55 trunk/Scripts/Bash/Functions/Shell
|
|
|
c2a1bc |
|
|
|
d11e55 |
|
|
|
c12cdc |
|
|
|
2c3589 |
3.55.1 Goals
|
|
|
2c3589 |
|
|
|
c12cdc |
This section exists to organize files related to shell
|
|
|
c12cdc |
functionality of <tt>`centos-art.sh'</tt> script.
|
|
|
2c3589 |
|
|
|
2c3589 |
|
|
|
c12cdc |
|
|
|
2c3589 |
3.55.2 Description
|
|
|
2c3589 |
|
|
|
c12cdc |
The shell functionality of <tt>`centos-art.sh'</tt> script helps
|
|
|
c12cdc |
you to maintain bash scripts inside repository. For example, suppose
|
|
|
c12cdc |
you've created many functionalities for <tt>`centos-art.sh'</tt> script,
|
|
|
c12cdc |
and you want to use a common copyright and license note for
|
|
|
c12cdc |
consistency in all your script files. If you have a bunch of files,
|
|
|
c12cdc |
doing this one by one wouldn't be a big deal. In contrast, if the
|
|
|
c12cdc |
amount of files grows, updating the copyright and license note for all
|
|
|
c12cdc |
of them would be a task rather tedious. The shell functionality
|
|
|
c12cdc |
exists to solve maintainance tasks just as the one previously
|
|
|
c12cdc |
mentioned.
|
|
|
2c3589 |
|
|
|
c12cdc |
When you use shell functionality to update copyright inside
|
|
|
c12cdc |
script files, it is required that your script files contain (at least)
|
|
|
c12cdc |
the following top commentary structure:
|
|
|
2c3589 |
|
|
|
c12cdc |
|
|
|
c12cdc |
1| #!/bin/bash
|
|
|
c12cdc |
2| #
|
|
|
c12cdc |
3| # doSomething.sh -- The function description goes here.
|
|
|
c12cdc |
4| #
|
|
|
c12cdc |
5| # Copyright
|
|
|
c12cdc |
6| #
|
|
|
c12cdc |
7| # ...
|
|
|
c12cdc |
8| #
|
|
|
c12cdc |
9| # ----------------------------------------------------------------------
|
|
|
c12cdc |
10| # $Id$
|
|
|
c12cdc |
11| # ----------------------------------------------------------------------
|
|
|
c12cdc |
12|
|
|
|
c12cdc |
13| function doSomething {
|
|
|
c12cdc |
14|
|
|
|
c12cdc |
15| }
|
|
|
d11e55 |
|
|
|
c12cdc |
Figure 3.4: The functions script base comment structure
|
|
|
c12cdc |
|
|
|
2c3589 |
|
|
|
c12cdc |
Relevant lines in the above structure are lines from 5 to 9.
|
|
|
c12cdc |
Everything else in the file is left immutable.
|
|
|
2c3589 |
|
|
|
c12cdc |
When you are updating copyright through shell
|
|
|
c12cdc |
functionality, the <tt>`centos-art.sh'</tt> script replaces everything
|
|
|
c12cdc |
in-between line 5 --the first one matching <samp>`^# Copyright .+$'</samp>
|
|
|
c12cdc |
string-- and line 9--the first long dash separator matching <samp>`^#
|
|
|
c12cdc |
-+$'</samp>-- with the content of copyright template instance.
|
|
|
2c3589 |
|
|
|
c12cdc |
Caution Be sure to add the long dash separator that matches
|
|
|
c12cdc |
<samp>`^# -+$'</samp> regular expression before the function
|
|
|
c12cdc |
definition. Otherwise, if the <samp>`Copyright'</samp> line is present but no
|
|
|
c12cdc |
long dash separator exists, <tt>`centos-art.sh'</tt> will remove anything
|
|
|
c12cdc |
in-between the <samp>`Copyright'</samp> line and the end of file. This way you
|
|
|
c12cdc |
may lost your function definitions entirely.
|
|
|
c12cdc |
|
|
|
7e35dc |
|
|
|
c12cdc |
The copyright template instance is created from one copyright template
|
|
|
c12cdc |
stored in the <tt>`Config/tpl_forCopyright.sed'</tt> file. The template
|
|
|
c12cdc |
instance is created once, and later removed when no longer needed. At
|
|
|
c12cdc |
this moment, when template instance is created, the
|
|
|
c12cdc |
<tt>`centos-art.sh'</tt> script takes advantage of automation in order to
|
|
|
c12cdc |
set copyright full name and date dynamically.
|
|
|
2c3589 |
|
|
|
c12cdc |
When you use shell functionality to update copyright, the first
|
|
|
c12cdc |
thing <tt>`shell'</tt> functionality does is requesting copyright
|
|
|
c12cdc |
information to user, and later, if values were left empty (i.e., no
|
|
|
c12cdc |
value was typed before pressing RET key), the <tt>`shell'</tt>
|
|
|
c12cdc |
functionality uses its own default values.
|
|
|
2c3589 |
|
|
|
c12cdc |
When shell functionality uses its own default values, the final
|
|
|
c12cdc |
copyright note looks like the following:
|
|
|
2c3589 |
|
|
|
c12cdc |
|
|
|
c12cdc |
1| #!/bin/bash
|
|
|
c12cdc |
2| #
|
|
|
c12cdc |
3| # doSomthing.sh -- The function description goes here.
|
|
|
c12cdc |
4| #
|
|
|
c12cdc |
5| # Copyright (C) 2003, 2010 The CentOS Project
|
|
|
c12cdc |
6| #
|
|
|
c12cdc |
7| # This program is free software; you can redistribute it and/or modify
|
|
|
c12cdc |
8| # it under the terms of the GNU General Public License as published by
|
|
|
c12cdc |
9| # the Free Software Foundation; either version 2 of the License, or
|
|
|
c12cdc |
10| # (at your option) any later version.
|
|
|
c12cdc |
11| #
|
|
|
c12cdc |
12| # This program is distributed in the hope that it will be useful, but
|
|
|
c12cdc |
13| # WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c12cdc |
14| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
c12cdc |
15| # General Public License for more details.
|
|
|
c12cdc |
16| #
|
|
|
c12cdc |
17| # You should have received a copy of the GNU General Public License
|
|
|
c12cdc |
18| # along with this program; if not, write to the Free Software
|
|
|
c12cdc |
19| # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
c12cdc |
20| # USA.
|
|
|
c12cdc |
21| #
|
|
|
c12cdc |
22| # ----------------------------------------------------------------------
|
|
|
c12cdc |
23| # $Id$
|
|
|
c12cdc |
24| # ----------------------------------------------------------------------
|
|
|
c12cdc |
25|
|
|
|
c12cdc |
26| function doSomething {
|
|
|
c12cdc |
27|
|
|
|
c12cdc |
28| }
|
|
|
d11e55 |
|
|
|
c12cdc |
Figure 3.5: The function script comment example
|
|
|
c12cdc |
|
|
|
d11e55 |
|
|
|
c12cdc |
Relevant lines in the above structure are lines from 5 to 22. Pay
|
|
|
c12cdc |
attention how the copyright line was built, and how the license was
|
|
|
c12cdc |
added into the top comment where previously was just three dots.
|
|
|
c12cdc |
Everything else in the file was left immutable.
|
|
|
d11e55 |
|
|
|
c12cdc |
To change copyright information (i.e., full name or year information),
|
|
|
c12cdc |
run the shell functionality over the root directory containing
|
|
|
c12cdc |
the script files you want to update copyright in and enter the
|
|
|
c12cdc |
appropriate information when it be requested. You can run the
|
|
|
c12cdc |
shell functionality as many times as you need to.
|
|
|
d11e55 |
|
|
|
c12cdc |
To change copyright license (i.e., the text in-between lines 7 and
|
|
|
c12cdc |
20), you need to edit the <tt>`Config/tpl_forCopyright.sed'</tt> file, set
|
|
|
c12cdc |
the appropriate information, and run the shell functionality
|
|
|
c12cdc |
once again for changes to take effect over the files you specify.
|
|
|
d11e55 |
|
|
|
c12cdc |
Important The <tt>`centos-art.sh'</tt> script is released as:
|
|
|
6a8116 |
|
|
|
c12cdc |
GNU GENERAL PUBLIC LICENSE
|
|
|
c12cdc |
Version 2, June 1991
|
|
|
7e35dc |
|
|
|
c12cdc |
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
|
|
c12cdc |
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
6a8116 |
|
|
|
c12cdc |
Do not change the license information under which <tt>`centos-art.sh'</tt>
|
|
|
c12cdc |
script is released. Instead, if you think a different license must be
|
|
|
c12cdc |
used, please share your reasons at CentOS Developers mailing list.
|
|
|
c12cdc |
|
|
|
c12cdc |
|
|
|
d11e55 |
|
|
|
2c3589 |
|
|
|
2c3589 |
3.55.3 Usage
|
|
|
d11e55 |
|
|
|
d11e55 |
|
|
|
c12cdc |
centos-art sh --update-copyright='path/to/dir'
|
|
|
c12cdc |
centos-art sh --update-copyright='path/to/dir' --filter='regex'
|
|
|
c12cdc |
Use these commands to update copyright information in <samp>`.sh'</samp> files
|
|
|
c12cdc |
under <samp>`path/to/dir'</samp> directory.
|
|
|
c12cdc |
|
|
|
6a8116 |
|
|
|
6a8116 |
|
|
|
c12cdc |
When you provide <samp>`--filter='regex''</samp> argument, the list of files
|
|
|
c12cdc |
to process is reduced as specified in <samp>`regex'</samp> regular expression.
|
|
|
c12cdc |
Inside <tt>`centos-art.sh'</tt> script, the <samp>`regex'</samp> regular
|
|
|
c12cdc |
expression is used in combination with find command to look
|
|
|
c12cdc |
for files matching the regular expression path pattern.
|
|
|
c12cdc |
|
|
|
c12cdc |
Warning In order for <samp>`regex'</samp> regular expression to match
|
|
|
c12cdc |
a file, the <samp>`regex'</samp> regular expresion must match the whole file
|
|
|
c12cdc |
path not just the file name.
|
|
|
c12cdc |
|
|
|
c12cdc |
|
|
|
c12cdc |
For example, if you want to match all <tt>`render.conf.sh'</tt> files
|
|
|
c12cdc |
inside <tt>`path/to/dir'</tt>, use the .+/render.conf regular
|
|
|
c12cdc |
expression. Later, <tt>`centos-art.sh'</tt> script uses this value inside
|
|
|
c12cdc |
^$REGEX\.sh$ expression in order to build the final regular
|
|
|
c12cdc |
expression (i.e., ^.+/render.conf\.sh$ ) that is evaluated
|
|
|
c12cdc |
against available file paths inside the list of files to process.
|
|
|
c12cdc |
|
|
|
c12cdc |
Exceptionally, when you provide <samp>`--filter='regex''</samp> in the way
|
|
|
c12cdc |
that <samp>`regex'</samp>, appended to <samp>`path/to/dir/'</samp> (i.e.
|
|
|
c12cdc |
<samp>`path/to/dir/regex'</samp>), matches a regular file; the
|
|
|
c12cdc |
<tt>`centos-art.sh'</tt> script uses the file matching as only file in the
|
|
|
c12cdc |
list of files to process.
|
|
|
d11e55 |
|
|
|
d11e55 |
|
|
|
2c3589 |
|
|
|
2c3589 |
3.55.4 See also
|
|
|
300762 |
|
|
|
4a9d2a |
|
|
|
c12cdc |
3.47 trunk/Scripts/Bash
|
|
|
2c3589 |
|
|
|
c12cdc |
3.48 trunk/Scripts/Bash/Functions
|
|
|
4a9d2a |
|
|
|
4a9d2a |
|
|
|
bc3531 |
|
|
|
38bcd9 |
|
|
|
300762 |
|
|
|
2c3589 |
[ < ]
|
|
|
2c3589 |
[ > ]
|
|
|
300762 |
|
|
|
300762 |
[ << ]
|
|
|
c12cdc |
[ Up ]
|
|
|
c12cdc |
[ >> ]
|
|
|
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>
|