@node unshar Invocation
@section Invoking unshar
@pindex unshar
@cindex unpack a shar archive
@ignore
#  -*- buffer-read-only: t -*- vi: set ro:
#
# DO NOT EDIT THIS FILE   (invoke-unshar.texi)
#
# It has been AutoGen-ed
# From the definitions    unshar-opts.def
# and the template file   agtexi-cmd.tpl
@end ignore
Unshar scans the input files (typically email messages) looking for
the start of a shell archive.  If no files are given, then standard
input is processed instead.  It then passes each archive discovered
through an invocation of the shell program to unpack it.

This section was generated by @strong{AutoGen},
using the @code{agtexi-cmd} template and the option descriptions for the @code{unshar} program.
This software is released under the GNU General Public License, version 3 or later.

@menu
* unshar usage::                  unshar help/usage (@option{--help})
* unshar directory::              directory option (-d)
* unshar overwrite::              overwrite option (-c)
* unshar force::                  force option (-f)
* unshar split-at::               split-at option (-E)
* unshar exit-0::                 exit-0 option (-e)
* unshar debug::                  debug option (-D)
* unshar config::                 presetting/configuring unshar
* unshar exit status::            exit status
* unshar Authors::                Authors
* unshar Bugs::                   Bugs
* unshar See Also::               See Also
@end menu

@node unshar usage
@subsection unshar help/usage (@option{--help})
@cindex unshar help

This is the automatically generated usage text for unshar.

The text printed is the same whether selected with the @code{help} option
(@option{--help}) or the @code{more-help} option (@option{--more-help}).  @code{more-help} will print
the usage text by passing it through a pager program.
@code{more-help} is disabled on platforms without a working
@code{fork(2)} function.  The @code{PAGER} environment variable is
used to select the program, defaulting to @file{more}.  Both will exit
with a status code of 0.

@exampleindent 0
@example
unshar (GNU sharutils) - unpack a shar archive
Usage:  unshar [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [<file>...]

   -d, --directory=DIR        unpack into the directory DIR
   -c, --overwrite            overwrite any pre-existing files
   -f, --force                an alias for the 'overwrite' option
   -E, --split-at=SPLIT-PAT   split input on SPLIT-PAT lines
   -e, --exit-0               split input on "exit 0" lines
                                - prohibits the option 'split-at'
   -D, --debug                debug the shell code
   -v, --version[=MODE]       output version information and exit
   -h, --help                 display extended usage information and exit
   -!, --more-help            extended usage information passed thru pager
   -R, --save-opts[=FILE]     save the option state to the config file FILE
   -r, --load-opts=FILE       load options from the config file FILE
                                - disabled as '--no-load-opts'
                                - may appear multiple times

Options are specified by doubled hyphens and their name or by a single
hyphen and the flag character.

If no arguments are provided, input arguments are read from stdin,
one per line; blank and '#'-prefixed lines are comments.
'stdin' may not be a terminal (tty).

The following option preset mechanisms are supported:
 - reading file $HOME/.sharrc

'unshar' scans the input files (typically email messages) looking for the
start of a shell archive.  If no files are given, then standard input is
processed instead.  It then passes each archive discovered through an
invocation of the shell program to unpack it.

Please send bug reports to:  <bug-gnu-utils@@gnu.org>
@end example
@exampleindent 4

@node unshar directory
@subsection directory option (-d)
@cindex unshar-directory

This is the ``unpack into the directory @file{dir}'' option.
This option takes a string argument @file{dir}.
The input file names are relative to the current directory
when the program was started.  This option tells @command{unshar}
to insert a @code{cd <dir>} commad at the start of the
@command{shar} text written to the shell.
@node unshar overwrite
@subsection overwrite option (-c)
@cindex unshar-overwrite

This is the ``overwrite any pre-existing files'' option.
This option is passed through as an option to the shar file.  Many
shell archive scripts accept a @option{-c} argument to indicate that
existing files should be overwritten.
@node unshar force
@subsection force option (-f)
@cindex unshar-force

This is an alias for the @code{overwrite} option,
@pxref{unshar overwrite, the overwrite option documentation}.

@node unshar split-at
@subsection split-at option (-E)
@cindex unshar-split-at

This is the ``split input on @var{split-mark} lines'' option.
This option takes a string argument @file{split-mark}.
With this option, @command{unshar} isolates each different shell archive
from the others which have been placed in the same file, unpacking each
in turn, from the beginning of the file to the end.  Its proper
operation relies on the fact that many shar files are terminated by a
readily identifiable string at the start of the last line.

For example, noticing that most `.signatures' have a double hyphen
("--") on a line right before them, one can then sometimes use
@code{--split-at=--}.  The signature will then be skipped, along with
the headers of the following message.
@node unshar exit-0
@subsection exit-0 option (-e)
@cindex unshar-exit-0

This is the ``split input on "exit 0" lines'' option.

@noindent
This option has some usage constraints.  It:
@itemize @bullet
@item
must not appear in combination with any of the following options:
split-at.
@end itemize

Most shell archives end with a line consisting of simply "exit 0".
This option is equivalent to (and conflicts with)
@code{--split-at="exit 0"}.
@node unshar debug
@subsection debug option (-D)
@cindex unshar-debug

This is the ``debug the shell code'' option.
"set -x" will be emitted into the code the shell interprets.


@node unshar config
@subsection presetting/configuring unshar

Any option that is not marked as @i{not presettable} may be preset by
loading values from configuration ("rc" or "ini") files.


@noindent
@code{libopts} will search in @file{$HOME} for configuration (option) data.
The environment variable @code{HOME, } is expanded and replaced when
the program runs
If this is a plain file, it is simply processed.
If it is a directory, then a file named @file{.sharrc} is searched for within that directory.

Configuration files may be in a wide variety of formats.
The basic format is an option name followed by a value (argument) on the
same line.  Values may be separated from the option name with a colon,
equal sign or simply white space.  Values may be continued across multiple
lines by escaping the newline with a backslash.

Multiple programs may also share the same initialization file.
Common options are collected at the top, followed by program specific
segments.  The segments are separated by lines like:
@example
[UNSHAR]
@end example
@noindent
or by
@example
<?program unshar>
@end example
@noindent
Do not mix these styles within one configuration file.

Compound values and carefully constructed string values may also be
specified using XML syntax:
@example
<option-name>
   <sub-opt>...&lt;...&gt;...</sub-opt>
</option-name>
@end example
@noindent
yielding an @code{option-name.sub-opt} string value of
@example
"...<...>..."
@end example
@code{AutoOpts} does not track suboptions.  You simply note that it is a
hierarchicly valued option.  @code{AutoOpts} does provide a means for searching
the associated name/value pair list (see: optionFindValue).

The command line options relating to configuration and/or usage help are:

@subsubheading version (-v)

Print the program version to standard out, optionally with licensing
information, then exit 0.  The optional argument specifies how much licensing
detail to provide.  The default is to print the license name with the version.  The licensing infomation may be selected with an option argument.
Only the first letter of the argument is examined:

@table @samp
@item version
Only print the version.
@item copyright
Name the copyright usage licensing terms.  This is the default.
@item verbose
Print the full copyright usage licensing terms.
@end table

@node unshar exit status
@subsection unshar exit status

One of the following exit values will be returned:
@table @samp
@item 0 (EXIT_SUCCESS)
Successful program execution.
@item 1 (EXIT_FAILURE)
There was an error in command usage.
@item 2 (EXIT_POPEN_PROBLEM)
cannot spawn or write to a shell process
@item 3 (EXIT_CANNOT_CREATE)
cannot create output file
@item 4 (EXIT_BAD_DIRECTORY)
the working directory structure is invalid
@item 5 (EXIT_NOMEM)
memory allocation failure
@item 6 (EXIT_INVALID)
invalid input, does not contain a shar file
@item 66 (EX_NOINPUT)
A specified configuration file could not be loaded.
@item 70 (EX_SOFTWARE)
libopts had an internal operational error.  Please report
it to autogen-users@@lists.sourceforge.net.  Thank you.
@end table
@node unshar Authors
@subsection unshar Authors
The @file{shar} and @file{unshar} programs is the collective work of
many authors.  Many people contributed by reporting problems,
suggesting various improvements or submitting actual code.  A list of
these people is in the @file{THANKS} file in the sharutils distribution.
@node unshar Bugs
@subsection unshar Bugs
Please put @samp{sharutils} in the subject line for emailed bug
reports.  It helps to spot the message.
@node unshar See Also
@subsection unshar See Also
shar(1)
