profile progressbar pr_routes ps pwdauth \
ramdisk rarpd rawspeed rcp readclock \
remsync rget rlogin \
- rotate rsh rshd service setup shar \
+ rotate rsh rshd service setup \
slip spell sprofalyze sprofdiff srccrc \
svclog svrctl swifi synctree sysenv \
syslogd tcpd tcpdp tcpstat telnet \
+++ /dev/null
-PROG= shar
-MAN=
-
-.include <bsd.prog.mk>
+++ /dev/null
-/* shar - make a shell archive Author: Michiel Husijes */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-static void error(char *progname, char *operation, char *filename);
-int main(int argc, char **argv);
-
-int main(argc, argv)
-int argc;
-char *argv[];
-{
- int argn;
- register int ch;
- register FILE *fp;
- int exitstatus;
- char *filename;
-
- exitstatus = 0;
- for (argn = 1; argn < argc; argn++) {
- filename = argv[argn];
- if ((fp = fopen(filename, "r")) == NULL) {
- error(argv[0], "opening ", filename);
- exitstatus = 1;
- } else {
- fputs("echo x - ", stdout);
- fputs(filename, stdout);
- fputs("\nsed '/^X/s///' > ", stdout);
- fputs(filename, stdout);
- fputs(" << '/'\n", stdout);
- while ((ch = getc(fp)) != EOF) {
- putchar('X');
- putchar(ch);
- while (ch != '\n') {
- ch = getc(fp);
- if (ch == EOF) break;
- putchar(ch);
- }
- if (ch == EOF) break;
- }
- fputs("/\n", stdout);
- if (ferror(fp)) {
- error(argv[0], "reading ", filename);
- exitstatus = 1;
- }
- if (fclose(fp) != 0) {
- error(argv[0], "closing ", filename);
- exitstatus = 1;
- }
- if (ferror(stdout)) break; /* lost already */
- }
- }
- fflush(stdout);
- if (ferror(stdout)) {
- error(argv[0], "writing ", "stdout");
- exitstatus = 1;
- }
- return(exitstatus);
-}
-
-static void error(progname, operation, filename)
-char *progname;
-char *operation;
-char *filename;
-{
- fputs(progname, stderr);
- fputs(": error ", stderr);
- fputs(operation, stderr);
- perror(filename);
-}
ping.1 playwave.1 prep.1 \
profile.1 ps.1 rcp.1 recwave.1 \
remsync.1 rget.1 rlogin.1 rsh.1 rz.1 \
- shar.1 spell.1 \
- svc.1 svrctl.1 \
+ spell.1 svc.1 svrctl.1 \
synctree.1 sysenv.1 sz.1 telnet.1 template.1 \
term.1 termcap.1 tget.1 time.1 \
truncate.1 umount.1 \
+++ /dev/null
-.TH SHAR 1
-.SH NAME
-shar \- shell archiver
-.SH SYNOPSIS
-\fBshar \fIfile ...\fR
-.br
-.de FL
-.TP
-\\fB\\$1\\fR
-\\$2
-..
-.de EX
-.TP 20
-\\fB\\$1\\fR
-# \\$2
-..
-.SH EXAMPLES
-.TP 20
-.B shar *.c >s
-# Collect C programs in shell archive
-.TP 20
-.B sh <s
-# Extract files from a shell archive
-.SH DESCRIPTION
-.PP
-The named files are collected together into a shell archive written onto
-standard output.
-The individual files can be extracted by redirecting the shell archive into
-the shell.
-The advantage of
-.I shar
-over
-.I ar
-is that \fIshar\fP archives can be read on almost any
-\s-2UNIX\s+2
-system, whereas numerous, incompatible versions of
-.I ar
-are in widespread use.
-Extracting the files from a shell archive requires that
-.I sed
-be accessible.
-.SH "SEE ALSO"
-.BR sh (1),
-.BR unshar (1).
printenv printf pwhash \
renice rev \
\
- sdiff sed seq shlock \
+ sdiff sed seq shar shlock \
shuffle sort split stat su \
tail tee tic touch tput \
tr true tsort tty ul uname unexpand unifdef \
--- /dev/null
+# $NetBSD: Makefile,v 1.8 1997/03/24 21:59:48 christos Exp $
+# @(#)Makefile 8.1 (Berkeley) 6/6/93
+
+MAN= shar.1
+SCRIPTS=shar.sh
+
+
+.include <bsd.prog.mk>
--- /dev/null
+.\" $NetBSD: shar.1,v 1.12 2012/03/22 07:58:19 wiz Exp $
+.\"
+.\" Copyright (c) 1990, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)shar.1 8.1 (Berkeley) 6/6/93
+.\"
+.Dd June 6, 1993
+.Dt SHAR 1
+.Os
+.Sh NAME
+.Nm shar
+.Nd create a shell archive of files
+.Sh SYNOPSIS
+.Nm
+.Ar
+.Sh DESCRIPTION
+.Nm
+writes an
+.Xr sh 1
+shell script to the standard output which will recreate the file
+hierarchy specified by the command line operands.
+Directories will be recreated and must be specified before the
+files they contain (the
+.Xr find 1
+utility does this correctly).
+.Pp
+.Nm
+is normally used for distributing files by
+.Xr ftp 1
+or
+.Xr mail 1 .
+.Sh EXAMPLES
+To create a shell archive of the program
+.Xr ls 1
+and mail it to Rick:
+.Bd -literal -offset indent
+cd ls
+shar `find . -print` \&| mail -s "ls source" rick
+.Ed
+.Pp
+To recreate the program directory:
+.Bd -literal -offset indent
+mkdir ls
+cd ls
+\&...
+\*[Lt]delete header lines and examine mailed archive\*[Gt]
+\&...
+sh archive
+.Ed
+.Sh SEE ALSO
+.Xr compress 1 ,
+.Xr mail 1 ,
+.Xr tar 1 ,
+.Xr uuencode 1
+.Sh HISTORY
+The
+.Nm
+command appeared in
+.Bx 4.4 .
+.Sh BUGS
+.Nm
+makes no provisions for special types of files or files containing
+magic characters.
+.Sh SECURITY CONSIDERATIONS
+It is easy to insert trojan horses into
+.Nm
+files.
+It is strongly recommended that all shell archive files be examined
+before running them through
+.Xr sh 1 .
+Archives produced using this implementation of
+.Nm
+may be easily examined with the command:
+.Bd -literal -offset indent
+egrep -v '^[X#]' shar.file
+.Ed
--- /dev/null
+#!/bin/sh -
+#
+# $NetBSD: shar.sh,v 1.3 2005/06/30 02:36:35 perry Exp $
+#
+# Copyright (c) 1990, 1993
+# The Regents of the University of California. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. Neither the name of the University nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# @(#)shar.sh 8.1 (Berkeley) 6/6/93
+#
+
+if [ $# -eq 0 ]; then
+ echo 'usage: shar file ...'
+ exit 1
+fi
+
+cat << EOF
+# This is a shell archive. Save it in a file, remove anything before
+# this line, and then unpack it by entering "sh file". Note, it may
+# create directories; files and directories will be owned by you and
+# have default permissions.
+#
+# This archive contains:
+#
+EOF
+
+for i
+do
+ echo "# $i"
+done
+
+echo "#"
+
+for i
+do
+ if [ -d $i ]; then
+ echo "echo c - $i"
+ echo "mkdir -p $i > /dev/null 2>&1"
+ else
+ echo "echo x - $i"
+ echo "sed 's/^X//' >$i << 'END-of-$i'"
+ sed 's/^/X/' $i
+ echo "END-of-$i"
+ fi
+done
+echo exit
+echo ""
+
+exit 0