How do I deal with (null) filenames?

Chris Torek chris at mimsy.UUCP
Thu Jul 27 21:23:13 AEST 1989


In article <2131 at jhunix.HCF.JHU.EDU> bio_zwbb at jhunix.HCF.JHU.EDU
(Dr. William B. Busa) writes:
>I am using some software which has a horrible bug -- it generates data
>files which have null names; for instance, ls will list these files as
>(null).001
>(null).002
>(null).003
>etc. These truly are nulls -- in an alphabetical directory listing, 
>they are listed *before* . and ..! 

They are not truly `nulls', they are the sequence left-paren n u l l
right-paren dot zero zero <digit>.  They come before `.' and `..' in
sorted directory listings because `(' comes before `.' in ASCII.

>My question is this: how can I change these to manageable filenames?

	% sh		# if using csh
	$ for i in '(null)'.*; do
	>	mv "$i" "`echo \"$i\" | sed 's/(null)/foo/'`"
	> done

The other thing to do is fix the software.  Probably a `helpful' C
library is receiving a call of the form

	char *p = NULL;
	int seq = 0;
	...
	(void) sprintf(buffer, "%s.%3d", p, seq);

and instead of crashing the program (thus pointing directly to the bug),
it is formatting `%s' with an argument of (char *)0 as the six-letter
sequence `(null)'.  Suns and 4.3BSD-tahoe machines do this, for instance.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list