[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: processing order for configuration files in /etc/network/interfaces.d



	Hi.

On Mon, Aug 27, 2018 at 04:49:06PM +0200, tomas@tuxteam.de wrote:
> On Mon, Aug 27, 2018 at 04:32:26PM +0300, Reco wrote:
> > 	Hi.
> > 
> > On Mon, Aug 27, 2018 at 09:08:19AM -0400, Greg Wooledge wrote:
> > > > Hm. Interfaces man page refers to wordexp(3), but this one doesn't say
> > > > anything about sorted results
> > > 
> > > In the absence of such information, the best thing to conclude is that
> > > the order is unspecified.  It may be using the raw unsorted directory
> > > contents from readdir(3), or it may be starting them all in parallel
> > > threads, in which case the order will be nondeterministic.
> > 
> > wordexp(3) invokes glob(3).
> > 
> > glob(3) states that one *needs* to specify GLOB_NOSORT to get resultes
> > pathnames in no particular order, as by default the result will be
> > sorted.
> > 
> > Unless I'm reading glibc source wrong, the only non-default argument
> > that wordexp(3) passes to glob(3) is GLOB_NOCHECK.
> 
> Thanks for looking into the source.
> 
> The remaining problem is, since the doc seems pretty fuzzy about that,
> whether one can rely on this behaviour, or whether this is just an
> implementation detail which can change under one at any time.

Assuming that glibc stays true to POSIX, 2001 standard - [1] says that:

The wordexp() function shall store the number of generated words into
pwordexp->we_wordc and a pointer to a list of pointers to words in
pwordexp->we_wordv. Each individual field created during field splitting
(see the Shell and Utilities volume of IEEE Std 1003.1-2001, Section
2.6.5, Field Splitting) or pathname expansion (see the Shell and
Utilities volume of IEEE Std 1003.1-2001, Section 2.6.6, Pathname
Expansion) shall be a separate word in the pwordexp->we_wordv list. The
words shall be in order as described in the Shell and Utilities volume
of IEEE Std 1003.1-2001, Section 2.6, Word Expansions.

Last sentence says to me that wordexp output should be always sorted.

Latest edition I could find - 2017 standard - [2] contains similar
wording.

Reco

[1] http://pubs.opengroup.org/onlinepubs/009695299/functions/wordexp.html

[2] http://pubs.opengroup.org/onlinepubs/9699919799/


Reply to: