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