Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Oct 2020 15:33:32 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Manish Jain <bourne.identity@hotmail.com>
Cc:        Ralf Mardorf <ralf-mardorf@riseup.net>, freebsd-questions@freebsd.org
Subject:   Re: sh scripting question
Message-ID:  <20201016153332.89f1418f.freebsd@edvax.de>
In-Reply-To: <DB8PR06MB644292D3C0309B5DADADF69BF6030@DB8PR06MB6442.eurprd06.prod.outlook.com>
References:  <d50ba2c9-617f-6842-ef89-f5933be8f8b3@hotmail.com> <DB8PR06MB64427D88E17F02711EE657A3F6030@DB8PR06MB6442.eurprd06.prod.outlook.com> <20201016113408.16d58d68@archlinux> <DB8PR06MB644292D3C0309B5DADADF69BF6030@DB8PR06MB6442.eurprd06.prod.outlook.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Fri, 16 Oct 2020 15:55:59 +0530, Manish Jain wrote:
> This is where I actually have an entirely different philosophy. When you 
> create a file with a leading - (or for that matter, weird characters 
> such as * anywhere in the filename), I think the filesystem driver (i.e. 
> the kernel) should throw a warning: "Do you really want a filename like 
> that ?"

The kernel is not responsible here. It's the VFS driver and
its interface to the UFS filesystem driver. Generally, there
are only two (!) characters that need special attention in
UFS: "/" with the meaning of directory separator, and NUL
(the null byte) as the string terminator. Any other characters
are valid. UFS simply interprets a few other characters as
special, such as "." and "..". The shell might treat other
characters in a specific way, such as "*" or "?", or "-" at
the beginning of a string (which _could_ be a filename; see
sh's "--" options processing terminator).



> Actually, I would go one step ahead and have kernel drivers and users 
> agree on a Unix Portable File Naming Convention, which should debar 
> rotten file names in the first place to everyone except the root user 
> (and even he should get a warning on violations).

You cannot. Stupid people do stupid things, and if you give
them a computer, you cannot even estimate the level of stupid
that can be emitted. Furthermore, stupid people write stupid
programs, and those will then generate filenames with freakish
names because some PHB claims "That's the rule! Obey it! Or else!"
So any kind of consensus would be hard, you cannot for anyone,
and in the end, it's just a suggestion that nobody really
follows...

Yes, I wish it would be different, but I'm old and grumpy. ;-)



> A few examples of what the Convention should debar:
> 
> - in the leading position

Understandable - could be an option.



> . in the trailing position

Why?



> * anywhere in the filename
> | anywhere in the filename

Add other shell-specific wildcards and operators, such as "?"
and "!" and "&", and redirection, parentheses, brackets, braces...
Depending on the shell in question, there could be a lot.



> Anyway, Robert's problem I do not think relates to weird filenames as 
> far as I can see.

Spaces in filenames is a common (and technically solved) problem.
I had to deal with it a lot, as well as with "filenames from the
stupid", that's why I'm honestly claiming they won't go away in
the future. :-)




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20201016153332.89f1418f.freebsd>