* and ? are valid infilenames, contrary to doc
A framework for modular scripting
Brought to you by:
konsolebox
The documentation for Extended Functions says:
'?' and '*' are an exemption since they can never be a valid part of a filename and may only represent an invalid filename if quoted.
But these are valid characters in filenames. It also says
Bracket characters '[' and ']' are also glob characters but are not easy to tell if those are quoted or not in scripts
But I don't see why it would be hard to tell if they were quoted...
Hi. It's all about detecting if a string is just plain text or a glob pattern. We decide if we should call find or not from it. Detecting a string if it has glob expressions may be easy but detecting if all aren't quoted is not. One easiest trick I've thought about how to do is by replacing all quote patterns with empty string e.g. ${__//'*'}, then test again if those characters still exists. This may be easy in shells like Bash but not in other simpler shells that doesn't have such functions, and we my have to use external commands like sed. The part where we detect if a string is a pattern or not is very speed critical and would give significant slow down in its operation if we use external commands or heavier functions like that. * and ? may be valid filename characters but they are rarely used for scripts and the advantage of detecting it over speed and convenience to the default pattern that doesn't use the options is pretty inessential. Same reason would apply to brackets.
Sorry for the late reply, and thanks for your comment,
konsolebox
Just found this again while reviewing my list of "watched" things.
I think at the time I hadn't grasped that the manual is referring to quoted globs to be interpreted by the function; I was thinking the shell expands globs first. Maybe the loadx example wasn't in the manual at the time, or maybe I just missed it.