tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

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



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


Home | Main Index | Thread Index | Old Index