Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Aug 1997 07:47:49 +0200
From:      j@uriah.heep.sax.de (J Wunsch)
To:        itojun@itojun.org
Cc:        wosch@apfel.de (Wolfram Schneider), cvs-committers@freebsd.org, cvs-all@freebsd.org, cvs-usrbin@freebsd.org, drepper@ipd.info.uni-karlsruhe.de (Ulrich Drepper)
Subject:   Re: cvs commit: src/usr.bin/shar shar.sh
Message-ID:  <19970829074749.WJ48805@uriah.heep.sax.de>
In-Reply-To: <10111.872815814@itojun.csl.sony.co.jp>; from itojun@itojun.org on Aug 29, 1997 09:50:14 %2B0900
References:  <p1ik9h6m2u6.fsf@panke.panke.de> <10111.872815814@itojun.csl.sony.co.jp>

next in thread | previous in thread | raw e-mail | index | archive | help
As itojun@itojun.org wrote:

> Index: shar.sh
> ===================================================================
> RCS file: /home/ncvs/src/usr.bin/shar/shar.sh,v
> retrieving revision 1.2
> diff -r1.2 shar.sh
> 44,45c44,45
> < 	if [ ! -e $i ]; then
> < 		echo "$i does not exist" 1>&2
> ---
> > 	if [ ! \( -d $i -o -r $i \) ]; then
> > 		echo "$i inaccessible or not exist" 1>&2
> 75c75
> < 		sed 's/^/X/' $i
> ---
> > 		sed 's/^/X/' $i || exit

Why not this way?  While i was at it, i made it safe for filenames
with spaces in them.  However, filenames with backslashes in them are
displayed wrong when extracting, since somebody once was convinced
that it is a good idea to implement SysV backslashisms in our echo(1).
Sigh.  Now i know why this was a bad idea.

cvs diff: Diffing shar
Index: shar/shar.sh
===================================================================
RCS file: /home/ncvs/src/usr.bin/shar/shar.sh,v
retrieving revision 1.2
diff -u -u -r1.2 shar.sh
--- shar.sh	1997/08/28 14:35:09	1.2
+++ shar.sh	1997/08/29 05:39:20
@@ -41,7 +41,7 @@
 
 for i
 do
-	if [ ! -e $i ]; then
+	if [ ! -e "$i" ]; then
 		echo "$i does not exist" 1>&2
 		exit 66		# EX_NOINPUT
 	fi
@@ -66,14 +66,16 @@
 
 for i
 do
-	if [ -d $i ]; then
+	if [ -d "$i" ]; then
 		echo "echo c - $i"
-		echo "mkdir -p $i > /dev/null 2>&1"
-	else
+		echo "mkdir -p \"$i\" > /dev/null 2>&1"
+	elif [ -f "$i" ]; then
 		echo "echo x - $i"
-		echo "sed 's/^X//' >$i << 'END-of-$i'"
-		sed 's/^/X/' $i
+		echo "sed 's/^X//' >\"$i\" << 'END-of-$i'"
+		sed 's/^/X/' "$i" || exit 69
 		echo "END-of-$i"
+	else
+		echo "$i is neither file nor directory, not archived" 1>&2
 	fi
 done
 echo exit

-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970829074749.WJ48805>