1.\" $OpenBSD: lndir.1,v 1.24 2013/08/14 06:32:30 jmc Exp $ 2.\" 3.\" Copyright (c) 1997, Jason Downs. All rights reserved. 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice, this list of conditions and the following disclaimer in the 12.\" documentation and/or other materials provided with the distribution. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS 15.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17.\" DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, 18.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24.\" SUCH DAMAGE. 25.\" 26.\" $XConsortium: lndir.man /main/9 1995/12/15 14:00:35 gildea $ 27.\" 28.\" Copyright (c) 1993, 1994 X Consortium 29.\" 30.\" Permission is hereby granted, free of charge, to any person obtaining 31.\" a copy of this software and associated documentation files (the 32.\" "Software"), to deal in the Software without restriction, including 33.\" without limitation the rights to use, copy, modify, merge, publish, 34.\" distribute, sublicense, and/or sell copies of the Software, and to 35.\" permit persons to whom the Software is furnished to do so, subject to 36.\" the following conditions: 37.\" 38.\" The above copyright notice and this permission notice shall be 39.\" included in all copies or substantial portions of the Software. 40.\" 41.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 42.\" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 43.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 44.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR 45.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 46.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 47.\" OTHER DEALINGS IN THE SOFTWARE. 48.\" 49.\" Except as contained in this notice, the name of the X Consortium shall 50.\" not be used in advertising or otherwise to promote the sale, use or 51.\" other dealings in this Software without prior written authorization 52.\" from the X Consortium. 53.\" 54.Dd $Mdocdate: August 14 2013 $ 55.Dt LNDIR 1 56.Os 57.Sh NAME 58.Nm lndir 59.Nd create a shadow directory of symbolic links to another directory tree 60.Sh SYNOPSIS 61.Nm lndir 62.Op Fl is 63.Op Fl e Ar exceptfile 64.Ar fromdir 65.Op Ar todir 66.Sh DESCRIPTION 67The 68.Nm 69program makes a shadow copy 70.Ar todir 71of a directory tree 72.Ar fromdir , 73except that the shadow is not 74populated with real files but instead with symbolic links pointing at 75the real files in the 76.Ar fromdir 77directory tree. 78This is usually useful for maintaining source code for 79different machine architectures. 80You create a shadow directory 81containing links to the real source, which you will have usually 82mounted from a remote machine. 83You can build in the shadow tree, and 84the object files will be in the shadow directory, while the 85source files in the shadow directory are just symlinks to the real 86files. 87.Pp 88This scheme has the advantage that if you update the source, you need not 89propagate the change to the other architectures by hand, since all 90source in all shadow directories are symlinks to the real thing: 91just change working directory to the shadow directory and recompile away. 92.Pp 93The 94.Ar todir 95argument is optional and defaults to the current directory. 96The 97.Ar fromdir 98argument may be relative (e.g.\& 99.Pa ../src ) 100and is relative to 101.Ar todir 102(not the current directory). 103.Pp 104If you add files, simply run 105.Nm 106again. 107New files will be silently added. 108Old files will be 109checked that they have the correct link. 110.Pp 111Deleting files is a more painful problem; the symlinks will 112just point into never never land. 113.Pp 114The options are as follows: 115.Bl -tag -width Ds 116.It Fl e Ar exceptfile 117Add the specified file to the list of excluded files/directories. 118This is effective in all directories searched by 119.Nm . 120This option may be specified as many times as needed. 121.Pp 122The following types of files are excluded by default: 123.Pp 124.Bl -dash -offset indent -compact 125.It 126files whose names end in 127.Sq ~ 128.It 129files whose names start with 130.Sq .# 131.It 132RCS, SCCS, CVS, and CVS.adm directories 133.El 134.It Fl i 135If a file in 136.Ar fromdir 137is a symbolic link, 138.Nm 139will make the same link in 140.Ar todir 141rather than making a link back to the (symbolic link) entry in 142.Ar fromdir . 143The 144.Fl i 145flag changes that behavior, 146i.e. it causes the program to not treat symbolic links in 147.Ar fromdir 148specially. 149The link created in 150.Ar todir 151will point back to the corresponding (symbolic link) file in 152.Ar fromdir . 153If the link is to a directory, this is almost certainly the wrong thing. 154.Pp 155This option exists mostly to emulate the behavior the C version of 156.Nm 157had in X11R6. 158Its use is not recommended. 159.It Fl s 160Suppresses status messages normally output as 161.Nm 162descends into each subdirectory. 163.El 164.Sh DIAGNOSTICS 165The program displays the name of each subdirectory it enters, followed 166by a colon. 167The 168.Fl s 169option suppresses these messages. 170.Pp 171A warning message is displayed if the symbolic link cannot be created. 172The usual problem is that a regular file of the same name already 173exists. 174.Pp 175If the link already exists but doesn't point to the correct file, the 176program prints the link name and the location where it does point. 177.Sh SEE ALSO 178.Xr find 1 , 179.Xr ln 1 , 180.Xr patch 1 181.Sh HISTORY 182.Nm 183was first distributed as part of X11. 184.Pp 185This version first appeared in 186.Ox 1.2 . 187.Sh BUGS 188The 189.Xr patch 1 190program gets upset if it cannot change the files. 191You should never run 192.Xr patch 1 193from a shadow directory anyway. 194.Pp 195To clear out all files before you can relink 196(if 197.Ar fromdir 198moved, for instance): 199.Bd -literal -offset indent 200$ find todir -type l -print0 | xargs -0 -r rm 201.Ed 202.Pp 203Find all files that are not directories: 204.Bd -literal -offset indent 205$ find . ! -type d -print0 206.Ed 207