Saving (unusual) linux filenames

Albert van der Horst albert at
Wed Sep 1 15:46:32 CEST 2010

In article <i5jirs$4ae$1 at>,
Grant Edwards  <invalid at invalid.invalid> wrote:
>On 2010-08-31, MRAB <python at> wrote:
>> On 31/08/2010 17:58, Grant Edwards wrote:
>>> On 2010-08-31, MRAB<python at>  wrote:
>>>> On 31/08/2010 15:49, AmFreak at wrote:
>>>>> Hi,
>>>>> i have a script that reads and writes linux paths in a file. I save the
>>>>> path (as unicode) with 2 other variables. I save them seperated by ","
>>>>> and the "packets" by newlines. So my file looks like this:
>>>>> path1, var1A, var1B
>>>>> path2, var2A, var2B
>>>>> path3, var3A, var3B
>>>>> ....
>>>>> this works for "normal" paths but as soon as i have a path that does
>>>>> include a "," it breaks. The problem now is that (afaik) linux allows
>>>>> every char (aside from "/" and null) to be used in filenames. The only
>>>>> solution i can think of is using null as a seperator, but there have to
>>>>> a cleaner version ?
>>>> You could use a tab character '\t' instead.
>>> That just breaks with a different set of filenames.
>> How many filenames contain control characters?
>How many filenames contain ","?  Not many, but the OP wants his
>program to be bulletproof.  Can't fault him for that.

As appending ",v" is the convention for rcs / cvs archives, I would
say: a lot. Enough to guarantee that all my backup tar's contain at
least a few.

>If I had a nickle for every Unix program or shell-script that failed
>when a filename had a space it it....

I'd rather have it fail for spaces than for comma's.

>> Surely that's a bad idea.
>Of course it's a bad idea.  That doesn't stop people from doing it.
>Grant Edwards               grant.b.edwards        Yow! !  Now I understand
>                                  at               advanced MICROBIOLOGY and
>                                th' new TAX REFORM laws!!

Economic growth -- being exponential -- ultimately falters.
albert at spe&ar& &=n

More information about the Python-list mailing list