std.path.getName(): Screwy by design?

Lars T. Kyllingstad public at kyllingen.NOSPAMnet
Tue Mar 1 07:52:43 PST 2011


On Tue, 01 Mar 2011 10:27:49 -0500, Steven Schveighoffer wrote:

> On Tue, 01 Mar 2011 10:08:14 -0500, Lars T. Kyllingstad
> <public at kyllingen.nospamnet> wrote:
> 
>> On Tue, 01 Mar 2011 09:52:50 -0500, Steven Schveighoffer wrote:
>>
>>> On Tue, 01 Mar 2011 09:31:18 -0500, Lars T. Kyllingstad
>>> <public at kyllingen.nospamnet> wrote:
>>>
>>>> On Tue, 01 Mar 2011 08:50:29 -0500, Nick Sabalausky wrote:
>>>>
>>>>> "Steven Schveighoffer" <schveiguy at yahoo.com> wrote in message
>>>
>>>>>> From this page: http://en.wikipedia.org/wiki/Filename, it appears
>>>>>> that really, the only disallowed character in unix filenames is
>>>>>> '/'. Even '*' is allowed as a filename.  How... horrible.
>>>>> I would actually feel very good to just simply not support such
>>>>> things. If some unix user is going to use such awful filenames they
>>>>> can just deal with the consequences. (And I'm *rarely* the kind of
>>>>> person to hold such a viewpoint on software development matters.)
>>>>
>>>> If you have a bunch of "reserved characters", that means more special
>>>> cases to worry about in code.  I say it's better to allow as many
>>>> characters as possible.
>>>
>>> You still have to worry about them, because the shell treats them
>>> specially.
>>>
>>> If there is a file named '*.d', and you type in rm *.d on the command
>>> line, guess what happens?
>>
>> If you are using a command line shell you ought to know better than
>> typing "rm *.d". :)  If you are using a GUI shell, you right-click and
>> select "Delete file", and nothing bad happens.
> 
> "should have known better" is an unsatisfying response to "I just
> *accidentally* deleted all my work."  You could tell that to someone who
> drives off a cliff, but isn't it also good to put up guard rails?

I know.  I was being a smartass. :)


> very very smart, experienced people sometimes do things without
> thinking. If we can do something really small to prevent catastrophic
> errors, I think it's worth it.  I think in close to 100% of cases, one
> never wants a file with \ or * in it, so the library disallowing it will
> not cause any issues.

Wait... are we still discussing the merits of various file systems, or 
are we now debating how Phobos should handle weird filenames?


> One time, I was unpacking a program that wanted to be unpacked in /, so
> it could put files in bin, lib, etc.  I accidentally unpacked it in the
> current directory.  Wanting to remove it and go to / in order to unpack,
> I typed rm -rf /.  Bad things happened :)  This is obviously not an
> example that could have been prevented, but it goes to show that
> sometimes we just type commands without thinking, and the less chance we
> have to make mistakes, the better.

Yeah, I remember typing "rm *" in the wrong directory once, and 
completely erasing a paper I'd been working on. :(  Back then I was using 
bash.  Now I use zsh, which warns me when I try to do foolish things like 
that.

-Lars


More information about the Digitalmars-d mailing list