How to delete a file with ^? chars in the name?

Jonathan I. Kamens jik at athena.mit.edu
Fri Jan 12 16:07:47 AEST 1990


In article <130103 at sun.Eng.Sun.COM>, lm at snafu.Sun.COM (Larry McVoy) writes:
>In article <1990Jan10.143111.3446 at virtech.uucp> jje at virtech.uucp (Jeremy J.
>Epstein) writes:
>>In article <130045 at sun.Eng.Sun.COM>, lm at snafu.Sun.COM (Larry McVoy) writes:
>>> $ cat > xxx.c
>>> #include <stdio.h>
>>> main()
>>> {
>>> 	char buf[255];
>>> 
>>> 	while (gets(buf))
>>> 		if (unlink(buf))
>>> 			perror(buf);
>>> }
>>> ^D
>>> $ cc xxx.c
>>> $ a.out
>>> ????H01.b
>>> ^D
>>Unfortunately this won't work since the shell is responsible
>>for expanding the ? and * wildcard characters, not the kernel
>>(just for fun, consider implementing a shell which used different
>>wildcard characters...it's only confusing to the user).
> 
>You're out of your mind.  The shell does not come inbetween a the keyboard
>and gets().

  OK, let's take this very simply and stop insulting each other.  This
is comp.unix.wizards, not alt.flame (Frankly, since this IS
comp.unix.wizards, it is completely unbelievable to me that we are ONCE
AGAIN having this stupid discussion.  It is explained in the Frequently
Asked Questions posting of comp.unix.questions, and even with that it
comes up every couple of months, or even more frequently than that.).

  The original poster complained that his file contained three delete
characters. Now, from his description of the problem, I would have to
question his conclusion that the characters in question are delete
characters; if ls displays them as ? or ^?, they could be any garbage
control character.

  Your solution, Mr. McVoy, therefore has two flaws.  First of all, it
appears to assume that the user can type whatever characters are in the
flawed filename (and that he also knows the correct characters to type),
and that gets will not choke on them.  Neither of these assumptions is
necessarily correct.

  Second, when you illustrate the use of the program, you show the user
typing three question marks ("???") in place of the three unknown
control characters.  Now, it's quite possible that yuou meant those
question marks to be delete characters (which, as I pointed out above,
isn't necessarily going to work either, since they quite possibly aren't
delete characters in the filename), but THAT'S NOT WHAT YOU TYPED.  What
you typed are question marks, and (as Mr. Epstein pointed out) the only
way question marks could possibly do any good is if you were expecting
them to be expanded somehow into the garbage control characters.

  Now, as several people have already pointed out, there is no need to
write special purpose programs to delete a file with a junk name, or to
rename it.  Several standard Unix utilities will very easily allow a
user to rename a file with a garbage name, except in extremeley rare
circumstances.  My personal preference is ls -li to get the inode number
and the find -inum to deal with it.

Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8495			      Home: 617-782-0710



More information about the Comp.unix.wizards mailing list