summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2025-04-15 17:29:06 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2025-04-19 10:22:43 -0700
commit66736fa3ffff50a46982c4ffd56ee7ab8a09704a (patch)
tree65cbe6ec7b14ee9e01a640d27f739723dd5e48e6
parentd7f9a5ceefa1a60ab3abfa575e0db97e5420a00b (diff)
Add -help and -version optionsHEADmaster
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/util/lndir/-/merge_requests/9>
-rw-r--r--lndir.c20
-rw-r--r--lndir.man22
2 files changed, 30 insertions, 12 deletions
diff --git a/lndir.c b/lndir.c
index 7b84fa7..872c0d7 100644
--- a/lndir.c
+++ b/lndir.c
@@ -91,6 +91,14 @@ quiterr (int code, const char *s)
exit (code);
}
+static void _X_NORETURN
+usage (int code, const char *prog_name)
+{
+ quit (code,
+ "usage: %s [-silent] [-ignorelinks] [-withrevinfo] fromdir [todir]",
+ prog_name);
+}
+
static void _X_ATTRIBUTE_PRINTF(1,2)
msg (const char * fmt, ...)
{
@@ -380,14 +388,20 @@ main (int argc, char *argv[])
++argv, --argc;
break;
}
+ else if ((strcmp(*argv, "-help") == 0) ||
+ (strcmp(*argv, "--help") == 0))
+ usage (EXIT_SUCCESS, prog_name);
+ else if ((strcmp(*argv, "-version") == 0) ||
+ (strcmp(*argv, "--version") == 0)) {
+ puts (PACKAGE_STRING);
+ exit (EXIT_SUCCESS);
+ }
else
break;
}
if (argc < 1 || argc > 2)
- quit (1,
- "usage: %s [-silent] [-ignorelinks] [-withrevinfo] fromdir [todir]",
- prog_name);
+ usage (EXIT_FAILURE, prog_name);
fn = argv[0];
if (argc == 2)
diff --git a/lndir.man b/lndir.man
index 984da99..aed0d0f 100644
--- a/lndir.man
+++ b/lndir.man
@@ -1,4 +1,3 @@
-.\" $Xorg: lndir.man,v 1.4 2001/02/09 02:03:17 xorgcvs Exp $
.\"
.\" Copyright (c) 1993, 1994, 1998 The Open Group
.\"
@@ -24,9 +23,6 @@
.\" other dealings in this Software without prior written authorization
.\" from The Open Group.
.\"
-.\"
-.\" $XFree86: xc/config/util/lndir.man,v 1.3tsi Exp $
-.\"
.TH LNDIR 1 __xorgversion__
.SH NAME
lndir \- create a shadow directory of symbolic links to another directory tree
@@ -43,9 +39,13 @@ lndir \- create a shadow directory of symbolic links to another directory tree
[
.I todir
]
+.PP
+.B lndir \-help
+|
+.B \-version
.SH DESCRIPTION
The
-.I lndir
+.B lndir
program makes a shadow copy
.I todir
of a directory tree
@@ -88,7 +88,7 @@ Files with names ending in \fI~\fP are never shadowed.
.PP
If you add files,
simply run
-.I lndir
+.B lndir
again. New files will be silently added. Old files will be
checked that they have the correct link.
.PP
@@ -96,14 +96,14 @@ Deleting files is a more painful problem; the symlinks will
just point into never never land.
.PP
If a file in \fIfromdir\fP is a symbolic link,
-\fIlndir\fP will make the same link in \fItodir\fP
+\fBlndir\fP will make the same link in \fItodir\fP
rather than making a link back to the
(symbolic link)
entry in \fIfromdir\fP.
The \fB\-ignorelinks\fP flag changes this behavior.
.SH OPTIONS
.IP "\-silent \&"
-Normally \fIlndir\fP outputs the name of each subdirectory as it
+Normally \fBlndir\fP outputs the name of each subdirectory as it
descends into it. The \fB\-silent\fP option suppresses these status
messages.
.IP \-ignorelinks
@@ -114,12 +114,16 @@ If the link is to a directory,
this is almost certainly the wrong thing.
.IP
This option exists mostly to emulate the behavior the C version of
-\fIlndir\fP had in X11R6. Its use is not recommended.
+\fBlndir\fP had in X11R6. Its use is not recommended.
.IP \-withrevinfo
Causes any source control manager subdirectories
(those named BitKeeper, CVS, CVS.adm, .git, .hg, RCS, SCCS, or .svn)
to be treated as any other directory,
rather than ignored.
+.IP \-help
+Print usage message and exit.
+.IP \-version
+Print version info and exit.
.SH DIAGNOSTICS
The program displays the name of each subdirectory it enters,
followed by a colon.