proc which (cmd)

	#  Figure out what will be run if cmd is typed.
	#  The search order is:
	#		1.	Aliases
	#		2.	Procedures
	#		3.	Executable files

	local save_nonovar
	@ save_nonovar = nonovar
	@ nonovar = 2
	if (`eval alias $cmd | wc -l`) then
		echo -n 'alias '
		eval alias $cmd
	else
		if (`eval proc $cmd | wc -l`) then
			echo -n 'proc  '
			eval proc $cmd
		else
			whereis $cmd |& head -1
		end
	end
	@ nonovar = save_nonovar
end

which $argv
