News for hackers. Stuff that matters.
Re:Why is the DOS path character "\"? (2005) by skissane on Friday February 26, 2021 @05:19AM (#26273270)
Another viewpoint: the problem is caused by Unix allowing any character in filenames (other than slash and null). Other platforms are more restrictive in what characters filenames are allowed to contain. If you banned the '-' character from starting a filename, the problem wouldn't happen.

I personally think Unix allowing almost any character in filenames was a mistake. You can put newlines and other control characters in filenames. That has very little legitimate use, and is a potential source of security and other bugs. There is a proposal to amend the Unix standards to disallow control characters in filenames. But it doesn't look like it is going to be successful: https://www.austingroupbugs.net/view.php?id=251

Re:Why is the DOS path character "\"? (2005) by kiwidrew on Friday February 26, 2021 @05:58PM (#26280847)
Agreed!

Shell scripting would be so much more sane (and safe) if filenames couldn't contain spaces (or control chars) and couldn't begin with a '-' character. Then the shell's default $IFS would work as intended in the presence of pathname expansion, and there would be no need to use '--' to delineate the filename arguments from the option arguments when executing commands.

Re:Why is the DOS path character "\"? (2005) by shaoonb on Friday February 26, 2021 @05:48AM (#26273452)
A coworker of mine got into trouble when he named a directory ~ and then tried to delete it.
Re:Why is the DOS path character "\"? (2005) by bobowzki on Friday February 26, 2021 @06:12AM (#26273584)
I once named a file $HOME and then carelessly tried to delete it without thinking twice.
Re:Why is the DOS path character "\"? (2005) by toast0 on Friday February 26, 2021 @10:08AM (#26275469)
> the problem is caused by Unix allowing any character in filenames (other than slash and null).

Most Unixes don't allow any character; they allow any byte other than ascii slash or zero. Turning bytes into characters is outside the scope of most Unix kernels and the filesystems therein.

Re:Why is the DOS path character "\"? (2005) by skissane on Friday February 26, 2021 @05:52PM (#26280812)
> Turning bytes into characters is outside the scope of most Unix kernels and the filesystems therein.

All the major contemporary Unix(-like) kernels do have code in them to do file path charset translation. It is very important when dealing with removable media (ISO-9660, UDF), FAT filesystems, network filesystems (especially CIFS/SMB, but even some NFS implementations), filesystems defined in terms of Unicode such as NTFS, HFS+, APFS.

Traditional Unix filesystems don't do this, but they were originally designed at a time when few clearly distinguished the concept of byte from the concept of character.