Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Oct 2020 15:33:32 +0200
From:      Polytropon <>
To:        Manish Jain <>
Cc:        Ralf Mardorf <>,
Subject:   Re: sh scripting question
Message-ID:  <>
In-Reply-To: <>
References:  <> <> <20201016113408.16d58d68@archlinux> <>

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

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


> * 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. :-)

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

Want to link to this message? Use this URL: <>