sh scripting question
freebsd at edvax.de
Fri Oct 16 13:33:43 UTC 2020
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. :-)
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
More information about the freebsd-questions