stow/dot-local/share/doc/stow/manual-split/Types-And-Syntax-Of-Ignore-Lists.html

183 lines
8.7 KiB
HTML

<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This manual describes GNU Stow version 2.3.2-fixbug56727
(2 November 2023), a program for managing farms of symbolic links.
Software and documentation is copyrighted by the following:
© 1993, 1994, 1995, 1996 Bob Glickstein <bobg+stow@zanshin.com>
© 2000, 2001 Guillaume Morin <gmorin@gnu.org>
© 2007 Kahlil (Kal) Hodgson <kahlil@internode.on.net>
© 2011 Adam Spiers <stow@adamspiers.org>
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided also that the
section entitled "GNU General Public License" is included with the
modified manual, and provided that the entire resulting derived work is
distributed under the terms of a permission notice identical to this
one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation
approved by the Free Software Foundation. -->
<title>Types And Syntax Of Ignore Lists (Stow)</title>
<meta name="description" content="Types And Syntax Of Ignore Lists (Stow)">
<meta name="keywords" content="Types And Syntax Of Ignore Lists (Stow)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link href="index.html" rel="start" title="Top">
<link href="Index.html" rel="index" title="Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Ignore-Lists.html" rel="up" title="Ignore Lists">
<link href="Justification-For-Yet-Another-Set-Of-Ignore-Files.html" rel="next" title="Justification For Yet Another Set Of Ignore Files">
<link href="Motivation-For-Ignore-Lists.html" rel="prev" title="Motivation For Ignore Lists">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
-->
</style>
</head>
<body lang="en">
<div class="section-level-extent" id="Types-And-Syntax-Of-Ignore-Lists">
<div class="nav-panel">
<p>
Next: <a href="Justification-For-Yet-Another-Set-Of-Ignore-Files.html" accesskey="n" rel="next">Justification For Yet Another Set Of Ignore Files</a>, Previous: <a href="Motivation-For-Ignore-Lists.html" accesskey="p" rel="prev">Motivation For Ignore Lists</a>, Up: <a href="Ignore-Lists.html" accesskey="u" rel="up">Ignore Lists</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Types-And-Syntax-Of-Ignore-Lists-1"><span>4.2 Types And Syntax Of Ignore Lists<a class="copiable-link" href="#Types-And-Syntax-Of-Ignore-Lists-1"> &para;</a></span></h3>
<p>If you put Perl regular expressions, one per line, in a
<samp class="file">.stow-local-ignore</samp> file within any top level package directory,
in which case any file or directory within that package matching any
of these regular expressions will be ignored. In the absence of this
package-specific ignore list, Stow will instead use the contents of
<samp class="file">~/.stow-global-ignore</samp>, if it exists. If neither the
package-local or global ignore list exist, Stow will use its own
built-in default ignore list, which serves as a useful example of the
format of these ignore list files:
</p>
<div class="example">
<pre class="verbatim"># Comments and blank lines are allowed.
RCS
.+,v
CVS
\.\#.+ # CVS conflict files / emacs lock files
\.cvsignore
\.svn
_darcs
\.hg
\.git
\.gitignore
.+~ # emacs backup files
\#.*\# # emacs autosave files
^/README.*
^/LICENSE.*
^/COPYING
</pre></div>
<p>Stow first iterates through the chosen ignore list (built-in, global,
or package-local) as per above, stripping out comments (if you want to
include the &lsquo;<samp class="samp">#</samp>&rsquo; symbol in a regular expression, escape it with a
blackslash) and blank lines, placing each regular expressions into one
of two sets depending on whether it contains the &lsquo;<samp class="samp">/</samp>&rsquo; forward
slash symbol.
</p>
<p>Then in order to determine whether a file or directory should be
ignored:
</p>
<ol class="enumerate">
<li> Stow calculates its path relative to the top-level package directory,
prefixing that with &lsquo;<samp class="samp">/</samp>&rsquo;. If any of the regular expressions
containing a &lsquo;<samp class="samp">/</samp>&rsquo; <em class="emph">exactly</em><a class="footnote" id="DOCF4" href="#FOOT4"><sup>4</sup></a> match
a subpath<a class="footnote" id="DOCF5" href="#FOOT5"><sup>5</sup></a> of this relative path, then the file or
directory will be ignored.
</li><li> If none of the regular expressions containing a &lsquo;<samp class="samp">/</samp>&rsquo; match in the
manner described above, Stow checks whether the
<em class="emph">basename</em><a class="footnote" id="DOCF6" href="#FOOT6"><sup>6</sup></a> of the file or directory matches
<em class="emph">exactly</em> against the remaining regular expressions which do not
contain a &lsquo;<samp class="samp">/</samp>&rsquo;, and if so, ignores the file or directory.
</li><li> Otherwise, the file or directory is not ignored.
</li></ol>
<p>For example, if a file <samp class="file">bazqux</samp> is in the <samp class="file">foo/bar</samp>
subdirectory of the package directory, Stow would use
&lsquo;<samp class="samp">/foo/bar/bazqux</samp>&rsquo; as the text for matching against regular
expressions which contain &lsquo;<samp class="samp">/</samp>&rsquo;, and &lsquo;<samp class="samp">bazqux</samp>&rsquo; as the text for
matching against regular expressions which don&rsquo;t contain &lsquo;<samp class="samp">/</samp>&rsquo;.
Then regular expressions &lsquo;<samp class="samp">bazqux</samp>&rsquo;, &lsquo;<samp class="samp">baz.*</samp>&rsquo;, &lsquo;<samp class="samp">.*qux</samp>&rsquo;,
&lsquo;<samp class="samp">bar/.*x</samp>&rsquo;, and &lsquo;<samp class="samp">^/foo/.*qux</samp>&rsquo; would all match (causing the
file to be ignored), whereas &lsquo;<samp class="samp">bar</samp>&rsquo;, &lsquo;<samp class="samp">baz</samp>&rsquo;, &lsquo;<samp class="samp">qux</samp>&rsquo;, and
&lsquo;<samp class="samp">o/bar/b</samp>&rsquo; would not (although &lsquo;<samp class="samp">bar</samp>&rsquo; would cause its parent
directory to be ignored and prevent Stow from recursing into that
anyway, in which case the file <samp class="file">bazqux</samp> would not even be
considered for stowing).
</p>
<p>As a special exception to the above algorithm, any
<samp class="file">.stow-local-ignore</samp> present in the top-level package directory
is <em class="emph">always</em> ignored, regardless of the contents of any ignore
list, because this file serves no purpose outside the stow directory.
</p>
</div>
<div class="footnotes-segment">
<hr>
<h4 class="footnotes-heading">Footnotes</h4>
<h5 class="footnote-body-heading"><a id="FOOT4" href="#DOCF4">(4)</a></h5>
<p>Exact matching means the
regular expression is anchored at the beginning and end, in contrast
to unanchored regular expressions which will match a substring.</p>
<h5 class="footnote-body-heading"><a id="FOOT5" href="#DOCF5">(5)</a></h5>
<p>In this context, &ldquo;subpath&rdquo; means a contiguous
subset of path segments; e.g for the relative path
<samp class="file">one/two/three</samp>, there are six valid subpaths: <samp class="file">one</samp>,
<samp class="file">two</samp>, <samp class="file">three</samp>, <samp class="file">one/two</samp>, <samp class="file">two/three</samp>,
<samp class="file">one/two/three</samp>.</p>
<h5 class="footnote-body-heading"><a id="FOOT6" href="#DOCF6">(6)</a></h5>
<p>The &ldquo;basename&rdquo; is the name of the file or
directory itself, excluding any directory path prefix - as returned by
the <code class="command">basename</code> command.</p>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="Justification-For-Yet-Another-Set-Of-Ignore-Files.html">Justification For Yet Another Set Of Ignore Files</a>, Previous: <a href="Motivation-For-Ignore-Lists.html">Motivation For Ignore Lists</a>, Up: <a href="Ignore-Lists.html">Ignore Lists</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Index.html" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>