NetBSD Problem Report #11107

Received: (qmail 5890 invoked from network); 1 Oct 2000 03:17:33 -0000
Message-Id: <20001001031711.12016.qmail@mailhost.dave.dtsp.co.nz>
Date: 1 Oct 2000 03:17:11 -0000
From: dave@dtsp.co.nz
Reply-To: dave@dtsp.co.nz
To: gnats-bugs@gnats.netbsd.org
Cc: dave@dtsp.co.nz
Subject: shar(1) is too forgiving of errors
X-Send-Pr-Version: 3.95

>Number:         11107
>Category:       bin
>Synopsis:       shar(1) is too forgiving of errors
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Oct 01 03:18:00 +0000 2000
>Closed-Date:    
>Last-Modified:  
>Originator:     Dave Sainty
>Release:        recent NetBSD-current
>Organization:
Dynamic Technology Services and Products Ltd (NZ)
>Environment:
System: NetBSD tequila.dave.dtsp.co.nz 1.5E NetBSD 1.5E (TEQUILA) #3: Sun Sep 10 17:28:10 NZST 2000 dave@tequila.dave.dtsp.co.nz:/vol/tequila/userB/u2/NetBSD-current/src/sys/arch/i386/compile/TEQUILA i386


>Description:
	If shar(1) is called with arguments including filenames that do not
	exist, it still terminates with exit level 0.

	This has an undesirable side-effect that is probably more correctly a
	GNU shar bug.  Using package "archivers/gsharutils", 'gshar' generates
	script that misbehaves in the presence of the NetBSD 'shar'.

>How-To-Repeat:
	cd /tmp
	touch foo
	gshar foo 2>/dev/null | sh
		sed: --print-text-domain-dir: No such file or directory
		x - creating lock directory
		x - SKIPPING foo (file already exists)

	Note the ugly 'sed' error, which is actually generated by shar(1).

>Fix:
The following patch causes shar(1) to abort immediately with 'exit 1' when a
file is not found.  'gshar' will still misbehave if a file
'--print-text-domain-dir' exists, but it isn't clear that 'shar' should be
held responsible for that.

As an added bonus, this patch also fixes some bugs related to special
characters in filesnames (but not all bugs).

--- src/usr.bin/shar/shar.sh.orig       Wed Dec 21 21:42:04 1994
+++ src/usr.bin/shar/shar.sh    Sun Oct  1 16:08:33 2000
@@ -60,13 +60,13 @@

 for i
 do
-       if [ -d $i ]; then
-               echo "echo c - $i"
-               echo "mkdir -p $i > /dev/null 2>&1"
+       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 "echo x - '$i'"
+               echo "sed 's/^X//' >'$i' << 'END-of-$i'"
+               sed 's/^/X/' "$i" || exit 1
                echo "END-of-$i"
        fi
 done
>Release-Note:
>Audit-Trail:
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.