Skip to content

Commit

Permalink
Custom from-scratch command-line parser for bsdtar. This is
Browse files Browse the repository at this point in the history
both more portable and more straightforward than the earlier
getopt()/getopt_long() wrapper approach, requires no fancy
configure/make glue to choose a platform implementation, and
gives me consistent command line parsing on every platform,
which should greatly simplify my attempts at building a robust
test suite.

I should have done this years ago.

SVN-Revision: 219
  • Loading branch information
kientzle committed Oct 6, 2008
1 parent fe41287 commit 27a6ba7
Show file tree
Hide file tree
Showing 7 changed files with 454 additions and 355 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Expand Up @@ -273,6 +273,7 @@ bsdtar_SOURCES= \
tar/bsdtar.c \
tar/bsdtar.h \
tar/bsdtar_platform.h \
tar/cmdline.c \
tar/getdate.y \
tar/matching.c \
tar/read.c \
Expand Down
2 changes: 1 addition & 1 deletion tar/Makefile
Expand Up @@ -2,7 +2,7 @@

PROG= bsdtar
BSDTAR_VERSION_STRING=2.5.5
SRCS= bsdtar.c getdate.y matching.c read.c siginfo.c subst.c tree.c util.c write.c
SRCS= bsdtar.c cmdline.c getdate.y matching.c read.c siginfo.c subst.c tree.c util.c write.c
WARNS?= 5
DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ}
LDADD= -larchive -lbz2 -lz
Expand Down
38 changes: 14 additions & 24 deletions tar/bsdtar.1
Expand Up @@ -144,21 +144,21 @@ In c and r mode, this changes the directory before adding
the following files.
In x mode, change directories after opening the archive
but before extracting entries from the archive.
.It Fl -check-links ( Fl W Cm check-links )
.It Fl -check-links
(c and r modes only)
Issue a warning message unless all links to each file are archived.
.It Fl -chroot ( Fl W Cm chroot )
.It Fl -chroot
(x mode only)
.Fn chroot
to the current directory after processing any
.Fl C
options and before extracting any files.
.It Fl -exclude Ar pattern ( Fl W Cm exclude Ns = Ns Ar pattern )
.It Fl -exclude Ar pattern
Do not process files or directories that match the
specified pattern.
Note that exclusions take precedence over patterns or filenames
specified on the command line.
.It Fl -format Ar format ( Fl W Cm format Ns = Ns Ar format )
.It Fl -format Ar format
(c, r, u mode only)
Use the specified format for the created archive.
Supported formats include
Expand Down Expand Up @@ -193,7 +193,7 @@ Synonym for
.It Fl I
Synonym for
.Fl T .
.It Fl -include Ar pattern ( Fl W Cm include Ns = Ns Ar pattern )
.It Fl -include Ar pattern
Process only files or directories that match the specified pattern.
Note that exclusions specified with
.Fl -exclude
Expand Down Expand Up @@ -225,7 +225,7 @@ automatically when reading archives.
Do not overwrite existing files.
In particular, if a file appears more than once in an archive,
later copies will not overwrite earlier copies.
.It Fl -keep-newer-files ( Fl W Cm keep-newer-files )
.It Fl -keep-newer-files
(x mode only)
Do not overwrite existing files that are newer than the
versions appearing in the archive being extracted.
Expand All @@ -245,28 +245,28 @@ By default, the modification time is set to the time stored in the archive.
.It Fl n
(c, r, u modes only)
Do not recursively archive the contents of directories.
.It Fl -newer Ar date ( Fl W Cm newer Ns = Ns Ar date )
.It Fl -newer Ar date
(c, r, u modes only)
Only include files and directories newer than the specified date.
This compares ctime entries.
.It Fl -newer-mtime Ar date ( Fl W Cm newer-mtime Ns = Ns Ar date )
.It Fl -newer-mtime Ar date
(c, r, u modes only)
Like
.Fl -newer ,
except it compares mtime entries instead of ctime entries.
.It Fl -newer-than Pa file ( Fl W Cm newer-than Ns = Ns Pa file )
.It Fl -newer-than Pa file
(c, r, u modes only)
Only include files and directories newer than the specified file.
This compares ctime entries.
.It Fl -newer-mtime-than Pa file ( Fl W Cm newer-mtime-than Ns = Ns Pa file )
.It Fl -newer-mtime-than Pa file
(c, r, u modes only)
Like
.Fl -newer-than ,
except it compares mtime entries instead of ctime entries.
.It Fl -nodump ( Fl W Cm nodump )
.It Fl -nodump
(c and r modes only)
Honor the nodump file flag by skipping this file.
.It Fl -null ( Fl W Cm null )
.It Fl -null
(use with
.Fl I ,
.Fl T ,
Expand Down Expand Up @@ -302,7 +302,7 @@ the archive will be discarded.
(c, r, u mode)
A synonym for
.Fl -format Ar ustar
.It Fl -one-file-system ( Fl W Cm one-file-system )
.It Fl -one-file-system
(c, r, and u modes)
Do not cross mount points.
.It Fl P
Expand Down Expand Up @@ -345,7 +345,7 @@ Extract files as sparse files.
For every block on disk, check first if it contains only NULL bytes and seek
over it otherwise.
This works similiar to the conv=sparse option of dd.
.It Fl -strip-components Ar count ( Fl W Cm strip-components Ns = Ns Ar count )
.It Fl -strip-components Ar count
(x and t mode only)
Remove the specified number of leading path elements.
Pathnames with fewer elements will be silently skipped.
Expand Down Expand Up @@ -418,16 +418,6 @@ Print version of
and
.Nm libarchive ,
and exit.
.It Fl W Ar longopt=value
Long options (preceded by
.Fl - )
are only supported directly on systems that have the
.Xr getopt_long 3
function.
The
.Fl W
option can be used to access long options on systems that
do not support this function.
.It Fl w
Ask for confirmation for every action.
.It Fl X Ar filename
Expand Down

0 comments on commit 27a6ba7

Please sign in to comment.