$ enshar README cars Unix > eg.shar
$ mailx -s 'Re: Please send me your brilliant stuff' \
>
p.scott@shu.ac.uk < eg.shar
$
You have to:
o work out how to use the shar file to extract the files it
contains,
o work out how it works, and
o write a shell script called `enshar' to produce shar files to
exactly the same format. (But your's won't have been e-mailed, so
they won't have any e-mail headers!)
Notice that `enshar' doesn't generate files directly; it only sends to
standard output. In the example, `eg.shar' was created because the
user redirected `enshar's output into `eg.shar'.
If `enshar' finds an error, it outputs an error message and executes an
`exit n'. The required error messages and the values of `n' are as
follows:
1 Usage: enshar file [ ... ]
2 enshar: <parameter>: can't be a pathname
3 enshar: <parameter>: is a directory
4 enshar: <parameter>: doesn't exist
5 enshar: <parameter>: can't be read
6 enshar: <parameter>: can't enshar
Notes:
o The first error message is given if the script is called without
parameters.
o The second error message is given if a parameter has a `/' character
in it.
o Error messages three to five are given if the file specified by a
parameter is: a directory, non-existant or unreadable.
o Error message six is given if the file specified by the parameter
contains the line that is used as the `here document' delimiter.
o `enshar' doesn't need to check all its parameters before generating
any output. That is, it can fail after outputting part of the shar
file. It would be an error for `enshar' to output anything else after
generating an error message.
6 In error messages two to six `<parameter>' should be replaced by the
value of the actual parameter that caused the problem.