Subject: Re: improving ash
To: VaX#n8 <vax@linkdead.paranoia.com>
From: Greg A. Woods <woods@kuma.web.net>
List: current-users
Date: 08/23/1996 10:23:38
[ On Sat, August 10, 1996 at 05:49:49 (-0500), vax@linkdead.paranoia.com wrote: ]
> Subject: improving ash
>
> More specifically, I'd like to add a "type" builtin and just maybe     
> a pattern matching builtin or two ("case" doesn't count :).
> I'd also like to fix whatever bug it is that seems to bomb out in
> large case statements of GNU autoconf scripts -- I may need to
> poke around in the NCASE/narg structure a bit.

me too!  ;-)

I suggested adding "type" to conform to other shells a very very long
time ago (before 0.9), but it never happened.  I've never had time to
write it as a C patch either, and I've ended up using the following
shell function, which ends up making my own persnal environment much
more portable to other *BSDs that also lack type(1):

#
#	.ashtype - This should be, but is not, a builtin in /bin/ash
#
#ident	"@(#)HOME:.ashtype	1.1	95/06/07 21:32:25 (woods)"

type () {
	if [ $# -ne 1 ]
	then
		echo "Usage: type command" >&2
		return 2
	fi
	hashv=`hash | grep "function $1\$"`
	if [ -n "$hashv" ]
	then
		echo "$hashv" | sed 's/^\([^ ]*\) \(.*\)$/\2 is a \1/'
		unset hashv
		return 0
	fi
	case "$1" in
	.|bg|bltin|cd|echo|eval|exec|exit|export|fg|getopts|hash|jobid|jobs|lc|local|pwd|read|readonly|return|set|setvar|shift|trap|umask|unset|wait)
		typeout="$1 is a builtin"
		;;
	*)
		typeout="$1 not found"
		oifs="$IFS"
		IFS=":"
		for pathseg in $PATH
		do
			if [ -x $pathseg/$1 ]
			then
				typeout="$1 is $pathseg/$1"
				break
			fi
		done
		IFS="$oifs"
		unset oifs
		;;
	esac
	echo $typeout
	unset hashv pathseg typeout
	return 0
}


-- 
							Greg A. Woods

+1 416 443-1734			VE3TCP			robohack!woods
Planix, Inc. <woods@planix.com>; Secrets Of The Weird <woods@weird.com>