WG15 Defect Report Ref: 9945-2-30
Topic: glob


This is an approved interpretation of 9945-2:1993.

.

Last update: 1997-05-20


								9945-2-30

	Class:  The ambiguous situation
	

The standard is unclear on this issue, and no conformance distinction
can be made between alternative implementations based on this.
This is being referred to the Sponsors of the standard.

 _____________________________________________________________________________

	Topic:			glob
	Relevant Sections:	B.8.2


Defect Report:
-----------------------

Please provide an interpretation of the following taken from Section B.8.2 of 
ISO/IEC 9945-2:1993.

On lines 547-549, the standard states:

  ``The argument pattern is a pointer to a pathname pattern to be expanded.
  The glob() function shall match all accessible pathnames against this 
  pattern and develop a list of all pathnames that match.''

This is clearly the appropriate behavior when pattern contains at least one 
unescaped metacharacter, but what if pattern is a simple string that doesn't 
match an existing accessible pathname? If taken at its face value, one might 
expect glob() to return GLOB_NOMATCH, but this is not the behavior of the 
shell in the same situation.  In particular, the shell only checks for matches 
of a command argument against accessible pathnames when there is at least one 
metacharacter in the argument.

I understand that the intent for glob() was to provide the shell's argument 
expansion through a simple API.  If this is correct, I would expect that only 
the presence of metacharacters will potentially cause glob() to return 
GLOB_NOMATCH.  If not, then an application would potentially be forced into 
scanning the pattern string on failure to determine whether a pattern 
replacement (due to a metacharacter) was at fault or because a simple string 
didn't match an existing pathname; such scanning would have to take escaping 
into account, as well as any potential ``extension'' metacharacters, so the 
process is not cheap.

A clarification of the intended behavior in this case is requested.

WG15 response for 9945-2:1993 
-----------------------------------


The standard is specific in its specification that this is the pattern
to be matched against, and that pglob->gl_pathc shall be zero if 
GLOB_NOCHECK is clear and there
is no match.  However, since it is not clearly stated that non-match
is a "failure", it is not clear that GLOB_NOMATCH is required to be
returned.  Therefore, glob() may return either zero or GLOB_NOMATCH.
Concern over wording of this area of the standard is being forwarded
to the sponsors of the standard.

Rationale for Interpretation:
-----------------------------
None.
 _____________________________________________________________________________