Re: Improving the performance of system boot by eliding unused rc.d scripts and caching the result

Martin Neitzel <[email protected]>
Newsgroups gmane.os.netbsd.devel.userlevel
Organization Gaertner Datensysteme, Marshlabs
Message-ID <[email protected]>
EF> > 	if (> /etc/rcorder.cache.tmp) 2>/dev/null; then
EF> I would have expected that to be
EF>  	if (:> /etc/rcorder.cache.tmp) 2>/dev/null; then
EF> and am suprised the shell accepts redirection on an empty command.

"> foo" is the standard idiom in Bourne-type shells to quickly
truncate a file to zero size, without messing up its ownership
or permissions.

The bloated variant ": > foo" is for old BSD farts like me who still
use the csh/tcsh which both do not accept a bare redirection:

	% > foo
	Invalid null command.
	% 

Both tcsh and POSIX sh define ":" as a built-in command, also accepting
(and ignoring) arguments.

The original/NetBSD's csh is a funny case.  Neither the man page
nor Bill Joy's "An Introduction to the C shell" mention any ":"
built-in.  Tests with "goto ''" make me believe that

	:

is actually parsed as a label statement with an empty label by csh,
making ": > foo" work almost by accident.

							Martin Neitzel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.