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

Re: ascii \177 char in filename



On Mon, May 21, 2001 at 05:23:37PM -0700, Mike Fedyk wrote:
> Hi,
> 
> I'm writing a script that will clean up netatalk shared files from their
> flaws from MacOS.
> 
> I have come accross a little snag though.
> 
> ls:
> ? Maria Rivier 1:2f00.doc
> 
> ls | od -a
> 0000000 del  sp   M   a   r   i   a  sp   R   i   v   i   e   r  sp   1
> 0000020   :   2   f   0   0   .   d   o   c  nl
> 0000032
> 
> ls | od -c
> 0000000 177       M   a   r   i   a       R   i   v   i   e   r       1
> 0000020   :   2   f   0   0   .   d   o   c  \n
> 0000032
> 
> As you can see, I'm having trouble with a file created by netatalk and it
> begins with ascii 177 (del) char.
> 
> How can I change the name for this file?
> 
> I've tried command completion, but no good.  Quoting doesn't work either.
> 
> Any help would be appreciated, and I can send the completed script to anyone
> interested.

That's plain evil.

---------- <badfile.c> ------------
#include <stdio.h>

const char filename[] = {127, ' ', 'M', 'a','r','i','a',' ', 
			'R','i','v','i','e','r',' ','1',':',
			'2','f','0','0','.','d','o','c',0};

int main (void)
{
	if (remove (filename) == -1)
		puts ("Success!");
	else
		puts ("Failure!");
	
	return 0;
}
--------- </badfile.c> -------------

$ gcc -o badfile badfile.c
$ ./badfile

Of course, a shell script with "tr" would probably be a better more
general solution (something like translating all non printable
characters to and underscore).

-- 
Eric G. Miller <egm2@jps.net>



Reply to: