On Thursday 10 January 2013 17:32, in comp.lang.c,
wrote:
> "Greg Martin" <> wrote in message
> news:_1HHs.63$...
>> On 13-01-10 01:34 PM, BartC wrote:
>
>>> It sounds like it will still be a problem under Linux
>
>> It's a feature not a problem.
>
> Suppose a program expects two parameters, both of which contain wildcards.
> The result will be a single list of files; how to tell where the first set
> of files ends, and the next begins? Or the second parameter should be a
> single file; how to tell whether that parameter was present? Etc.
>
>> It's part of the shell you are running - I'm guessing bash? You can use
>> the built-in set and turn it off:
>>
>> set -o noglob
>
> I've have a look later. If that works, that's good. But I can see
> problems: it'll work on my system, but someone else running my program
> will also have to do that set command. And it might stop other programs
> working properly that expect the expansion.
Please note that you are asking for a change of behaviour in the execution
environment, that is outside of the scope of the C language. Filename
globbing (or lack of it) is not part of the C standard; if you require your
program to perform it's own globbing, then you must use some utility
(likely an API) that is outside of the C standard. Each execution
environment will have it's own unique support, or perhaps no support at
all, for program-directed globbing.
Also note that, in most environments, the behaviour that you are asking for
is governed by well-known options /in that environment/. In POSIX/SUS
environments, globbing is done by the shell, and the facilities to disable
globbing are well known (set -o noglob, or even singlequoting the
argument).
You are trying to address a human-factors problem ("how to know to turn off
globbing when using this program") with code; never a good idea.
Here's the best advice:
** DOCUMENT THE REQUIREMENT IN THE OPERATING INSTRUCTIONS **
Wasn't that simple?
HTH
--
Lew Pitcher
"In Skills, We Trust"