Subject: pkg/6127: tcsh default path differs from that of other shells and contains dot
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jbernard@ox.mines.edu>
List: netbsd-bugs
Date: 09/08/1998 11:52:41
>Number:         6127
>Category:       pkg
>Synopsis:       tcsh default path differs from that of other shells and contains dot
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Sep  8 13:05:01 1998
>Last-Modified:
>Originator:     Jim Bernard
>Organization:
	Speaking for myself
>Release:        September 8, 1998
>Environment:
System: NetBSD io 1.3H NetBSD 1.3H (FIZ) #0: Fri Sep 4 14:08:51 MDT 1998 jbernard@io:/var/tmp/compile/sys/arch/i386/compile/FIZ i386


>Description:
	The default path used by tcsh if PATH is not defined in the
	environment is constructed on the fly, based on some OS-dependent
	pathnames, but ultimately differs from the defaults used by the
	native NetBSD shells.  In addition, the package does not configure
	the shell to exclude "." from the default path (this will turn out
	to be unnecessary, though, in the fix presented below).

>How-To-Repeat:
	/bin/sh                (spawn a subshell)
	unset PATH             (remove PATH from environment)
	/usr/pkg/bin/tcsh -f   (start tcsh without reading startup files)
	echo $PATH             (note that PATH is unset)
	echo $path             (but path is set, differs from the default
				used by /bin/sh and /bin/csh, and includes ".")

>Fix:
	This adds two new patch files, patch-ah, and patch-ai.  The
	former adds inclusion of <paths.h> to "pathnames.h".  The
	latter modifies sh.c to call importpath() on _PATH_DEFPATH 
	if the latter is defined (it's defined in <paths.h>, which is
	now included by sh.c via the chain "sh.h" --> "pathnames.h"
	--> <paths.h>), instead of using the defaultpath() function
	to set up the path (defaultpath() is used if _PATH_DEFPATH is
	not defined, but that should never occur on a NetBSD system
	if <paths.h> is included).

# 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:
#
#	patch-ah
#	patch-ai
#
echo x - patch-ah
sed 's/^X//' >patch-ah << 'END-of-patch-ah'
X$NetBSD$
X
X+++ pathnames.h	Tue Sep  8 09:36:37 1998
X@@ -37,6 +37,8 @@
X #ifndef _h_pathnames
X #define _h_pathnames
X 
X+#include <paths.h>
X+
X #if defined(CMUCS) && !defined(_PATH_LOCAL)
X # define _PATH_LOCAL		"/usr/cs/bin"
X #endif /* CMUCS && !_PATH_LOCAL */
END-of-patch-ah
echo x - patch-ai
sed 's/^X//' >patch-ai << 'END-of-patch-ai'
X$NetBSD$
X
X+++ sh.c	Tue Sep  8 09:58:52 1998
X@@ -648,7 +648,11 @@
X      * Re-initialize path if set in environment
X      */
X     if ((tcp = getenv("PATH")) == NULL)
X+#ifdef _PATH_DEFPATH
X+	importpath(str2short(_PATH_DEFPATH));
X+#else /* !_PATH_DEFPATH */
X 	setq(STRpath, defaultpath(), &shvhed, VAR_READWRITE);
X+#endif /* _PATH_DEFPATH */
X     else
X 	/* Importpath() allocates memory for the path, and the
X 	 * returned pointer from SAVE() was discarded, so
END-of-patch-ai
exit

>Audit-Trail:
>Unformatted: